Category: Spring Boot
-
Internationalization (i18n) in Spring Boot
Internationalization (i18n) is the process of designing applications that can be adapted to different languages and regions without requiring code changes. In Spring Boot, this is typically achieved using MessageSource to manage locale-specific messages and configuring locale resolvers. 1. Setting Up MessageSource Bean Spring Boot automatically loads messages from property files in the src/main/resources directory.…
-
RestClient introduced in Spring Boot 3.2
The RestClient is a synchronous HTTP client that offers a modern, fluent API. It offers an abstraction over HTTP libraries that allows for convenient conversion from a Java object to an HTTP request, and the creation of objects from an HTTP response. Creating a RestClient The RestClient is created using one of the static create methods. You can also use builder() to get a…
-
Spring Boot password encryption for application properties file using Jasypt
1. Introduction In this tutorial, we’ll learn how to encrypt sensitive information in Spring Boot application configuration file (application.properties or application.yml), such as username and password of datasource using Jasypt library. When you create a Spring Boot application, you keep properties in configuration files (application.properties or application.yaml). You should not keep sensitive configuration values in…
-
Configure custom DataSource in Spring Boot
1. Introduction If spring-boot-starter-data-jpa dependency is used, Spring will try to configure the DataSource. You just have to provide the connection details in the property file to get started. However, if you have requirement to create your own DataSource, Spring allows you to do that. In this tutorial, we’ll discuss how to configure custom DataSource…
-
Documenting a Spring REST API Using OpenAPI 3.0
1. Introduction We need documentation to understand the code or a program. For example, documentation helps us understand what a method does and what it needs as arguments to perform the operation. Similarly, API documentation can also be generated which will be helpful to provide description, request and response format. Swagger is the most popular…
-
Spring Boot with Hibernate
In this tutorial, we’ll discuss how to integrate Spring Boot and Hibernate. In this tutorial, we’ll create a REST application and will integrate Hibernate. Step 1: Create a Spring Boot application with Hibernate dependencies In this tutorial we are using MySql as database. We’ll create a Spring Boot application with following dependencies: spring-boot-starter-data-jpa spring-boot-starter-web mysql-connector-java…
-
Spring Boot Actuator
1. Introduction We know that Spring Boot is an opinionated framework i.e. can be configured based on our definitions (‘starter’ dependencies we use). Spring Boot provides production ready features to monitor and manage your application by using Actuator module. In this tutorial, we’ll discuss Spring Boot Actuator. Spring Boot Actuator module allows you to manage…
-
Logging in Spring Boot
1. Introduction In this tutorial, we’ll discuss logging in Spring Boot. Spring Boot makes it very easy to implement logging in application. You can use all popular logging frameworks like Commons Logging, Log4J, or SLF4J with Spring Boot. Spring Boot makes it very easy to use logging frameworks and comes with default configurations. Generally, you’ll…
-
Disable banner in Spring boot
1. Introduction When Spring Boot application is started, a banner is printed. The banner looks like the following: Sometimes you may want to customize this banner. For example, if you want to show the name of your application or product at application startup, you can choose to customize the banner. You can also choose not…
-
Custom banner in Spring Boot
1. Introduction Whenever Spring Boot application is started, a banner is printed. The banner looks like the following: This startup banner can be customized. We can use custom text as well as image. 2. How to customize banner in Spring Boot? There are two ways to change the banner: Adding banner.txt file in classpath. In…