RESTful Web Services

Multiple data source implementations are very crucial in instances where we want to secure the application from vulnerabilities such as a database failure. This will ensure that the application can still function even if part of the database went down. This tutorial will use student and course entities to demonstrate how multiple data sources can…

Read More Multiple Datasources in Spring Application

In this short tutorial, I am going to share with you how to switch your Spring Boot application, at runtime, to use a different logging level. Set Logging Level for a Package in Your App Suppose we have a Spring Boot Application with the following method in a Rest Controller class. @RestController @RequestMapping(“/users”) public class…

Read More Switch Logging Level in Spring Boot at Runtime

In this tutorial, you will learn how to use @AuthenticationPrincipal annotation to get the Jwt object containing the details of a provided in HTTP Request access token. When we send a request containing an access token in the Authorization header, behind the scenes,  Spring Framework will do a lot of work and if all is good,…

Read More @AuthenticationPrincipal – Getting the Jwt Claims

By default, Spring Boot RESTful web service endpoints consume and produce JSON representations. However, it’s possible to enable consuming XML and producing it for your REST API endpoints with minimal effort. This tutorial will guide you through the process of adding XML support to your Spring Boot application, allowing consuming XML and producing representations of…

Read More Consuming XML in Spring Boot REST

HATEOAS is a way to make your RESTful Web Service endpoint, automatically include links to other Resources of your API, in the response that it sends back to a calling client application.  The client application that consumes your web service endpoint, can then use those links, to consume other RESTful Resources that your Web Service…

Read More Add HATEOAS to Spring Boot RESTful Web Service

In this Spring Security tutorial, you will learn how to use the @PreAuthorize annotation to secure method invocation. You can use the @PreAuthorize annotation to secure either method in a Controller class or a method in a service layer class. There are other useful method-level security annotations like the ones below. It is useful to…

Read More Spring Security @PreAuthorize Annotation Example

In this tutorial, you will learn how to make Zuul API Gateway pass an Authorization header to a downstream Microservice. To learn how to make Spring Boot Microservice read HTTP Request headers, please read this tutorial: Read HTTP Request Header in Spring MVC. Configure Zuul API Gateway to Forward an Authorization Header By default, Zuul…

Read More Pass Authorization Header to Downstream Microservice

In this tutorial, I will share how to generate a self-signed certificate and enable HTTPS/SSL support in a Spring Boot application. You will also learn how to configure the RestTemplate HTTP client to use the same self-signed certificate to communicate with your Web Service over HTTPS. Let’s start by generating a self-signed certificate. Generate Self-Signed…

Read More Enable HTTPs/SSL in Spring Boot App

In this Spring Boot tutorial, you will learn how to get the details of the currently authenticated principal user. There is more than one way to get currently authenticated user details and in this blog post, I am going to share with you a few. Most likely you already have Spring Security configured for your…

Read More Spring Security. Get Authenticated Principal Details.

In this Spring Boot tutorial, you will learn how to implement User Authentication(User Login) functionality for your RESTful Web Service application. There is also a step-by-step video demonstration on how to do User Authentication available here. The user authentication functionality we are going to implement in this tutorial will work the following way: A user…

Read More User Authentication – Spring Boot, Spring Security, JWT

This tutorial will teach you how to bind nested properties from the application.properties file to a Java class. Once you finish this tutorial, you might also want to check: How to bind simple(not nested) properties to a Java class, and How to use @ConfigurationProperties with Spring Boot @Profile. Example of Nested Properties in a Properties File…

Read More Spring Boot Nested Properties with @ConfigurationProperties

In this tutorial, you will learn how to use @ConfigurationProperties with Spring Boot Profiles. This tutorial assumes you have a basic knowledge of how to use @ConfigurationProperties in your Spring Boot application. If you are very new to it, please read this tutorial: Spring Boot @ConfigurationProperties Tutorial. You should also have basic knowledge of Spring Boot…

Read More Using Spring Boot @ConfigurationProperties and @Profile

@ConfigurationProperties annotation is used to bind all the properties in a properties file to a Java class. You can then use an object of the Java class annotated with ConfigurationProperties annotation to access configuration properties defined in a properties file. Earlier I shared with you a tutorial on how to read application properties in Spring Boot RESTful…

Read More Spring Boot @ConfigurationProperties Tutorial

In this tutorial, you will learn how to use Spring Boot Profiles. You can use Spring Boot Profile functionality when providing application configuration for a specific environment. For example, when your application runs in a development environment, then your application will use a specific for that environment application.properties file. And when you are ready to…

Read More Spring Boot Profiles Tutorial

In this tutorial, you will learn how to use Spring Cloud Bus to notify running Microservices about the changes in the Spring Cloud Config property file. Running Microservices will be updated with new properties stored in Spring Cloud Config file without the need for you to restart them. This way you can update values in…

Read More Spring Cloud Bus – Refreshing Config Changes