Spring Boot + Spring Security + OAuth2

In this tutorial we explain how to secure a Spring Boot application using OAuth2. If you follow the steps in order, you’ll get a fully working secured application which authenticates user requests through Google API. Prerequisites: Eclipse IDE (neon release) Maven 4 Java 1.8 Spring Boot 2.0.0 1- Create maven project Open eclipse then create a new maven project and...

How to handle HTTP 403 forbidden error in Java

Sometimes when trying to consume a web service from a java client, you get a 403 forbidden HTTP response code, even though the service is accessible normally from web browsers. The HTTP 403 forbidden error doesn’t necessarily occur due to missing authentication attributes, some web services would only authorize web browsers or some specific clients to access them, while they...

How to exclude a URL from a Filter

By default, filters doesn’t support excluding a specific URL pattern, whenever you define a URL pattern for a filter then any request matching this pattern is handled by the filter without exceptions. The simplest way for excluding URLs from a filter is to map your filter to a very specific pattern. This is feasible when done in early development stages,...

Spring Boot + JPA + Hibernate + Oracle

In this tutorial we show how to create a Spring Boot application that communicates with an Oracle data source through Hibernate. Prerequisites: Eclipse IDE (neon release) Maven 4 Java 1.8 1- Create maven project Open eclipse, then create a new maven project and name it as SpringBootHibernate. At the end of this tutorial, we’ll get the following project structure: 2-...

How to change the default port of Spring Boot application

By default, Spring Boot applications run on an embedded Tomcat via port 8080. In order to change the default port, you just need to modify server.port attribute which is automatically read at runtime by Spring Boot applications. In this tutorial, we provide the common ways of modifying server.port attribute. 1- application.properties Create application.properties file under src/main/resources and define server.port attribute...

Build REST Web Service using Spring Boot

This tutorial provides a step-by-step guide on how to build a restfull web service using Spring Boot. Prerequisites: Eclipse IDE (neon release) Maven 4 Java 1.8 1. Create maven web project Open eclipse then create a new maven web project and name it as SpringBootRest. The structure of the generated project looks like the following: 2. pom.xml After creating the web project, the...

Create a Web Application With Spring Boot

This guide shows how to create a simple MVC web application using Spring Boot. Prerequisites: Eclipse IDE (neon release) Maven 4 Java 1.8 1. Create maven web project Open eclipse then create a new maven web project and name it as SpringBootWebJsp. The structure of the generated projects look like the following: 2. pom.xml After creating the web project, the...

Deploy JAX-WS service on tomcat

This tutorial provides a step-by-step guide on how to build and deploy JAX-WS web service on Tomcat. Throughout this tutorial, we create a very simple SOAP web service and finally deploy it on Tomcat application server. Prerequisites: Eclipse IDE (Neon release) Java 1.8 Apache Tomcat 8 1. Create Maven web project Create a maven web project using this tutorial and name your...

Build SOAP service with JAX-WS

JAX-WS is an API used for building and consuming XML web services in Java, it was first released in Java EE5. In this tutorial, we provide a step-by-step guide on how to build SOAP web service with JAX-WS and finally publishing it using Endpoint built-in class. Prerequisites: Eclipse IDE (Neon release) Java 1.8 1. Create standalone Java project Open eclipse,...

Deploy Spring Boot application on external Tomcat

Spring Boot provides an embedded servlet container which makes it very easy to setup and deploy web applications, by default all Spring Boot applications are exported as a runnable jar file and developers would only need to run this jar file on a java environment without the need to worry about installing and setting up servlet containers. However, the embedded...