Spring Boot

In this tutorial, you will learn how to start your Spring Boot application on a random port number. This is very helpful when you need to start multiple instances of the same Spring Boot application and then balance HTTP requests between the running instances. If you are interested to learn how to balance HTTP requests…

Read More Start Spring Boot App on a Random Port Number

In this tutorial, you will learn how to start your Spring Boot Web application on a different port number. By default, if no port number is configured, our Spring Boot Web application will start on port number 8080. To configure a different port number, you will need to update an application.properties file with the following…

Read More Start Spring Boot App on a Different Port Number

In this tutorial, you will learn how to configure your Spring Boot application to log messages to a file. Specify File Path To make your application log messages to a file, you will need to configure a couple of new properties in the application.properties file. logging.file.path=/path/to/a/file logging.file.name=log.txt You might also need to enable a specific logging…

Read More Log to File in Spring Boot

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

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 representation. But we can easily make our RESTful Spring Boot Web service endpoints consume and produce an XML representation of a resource as well. Add XML Support to Spring Boot Project To make our Spring Boot project consume and produce an XML representation…

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 tutorial, you will learn how to create an instance of @LoadBalanced RestTemplate and make it communicate with an internal microservice. For a step by step series of video lessons, please check this page: Spring Boot Microservices and Spring Cloud. Create RestTemplate Bean To create an instance of RestTemplate, you will need to first…

Read More @LoadBalanced RestTemplate Call Internal Microservice

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…

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 am going to share with you how to generate a self-signed certificate and enable HTTPs/SSL support in a Spring Boot application. You will also learn how to configure 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…

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 Security tutorial, you will learn how to use Spring method-level security to secure RestController methods with @PreAuthorize annotation. If you are interested in video lessons, then I also show how to create user Roles and Authorities and how to use Spring Method Level Security annotations in my video course: RESTful Web…

Read More Spring Method-Level Security. Secure RestController Methods

Free Video Lessons

Enter your email and stay on top of things,

Subscribe!