Debugging Auto-Configuration

In order to debug any production issue, we should know what auto-configurations are applied to the application. Learn how to debug the Spring Boot auto-configuration.

Auto-configuration report

Upon starting the application, we don’t get a lot of information of how Spring Boot decided to compose our applications through auto-configuration.

For debugging purposes, it’s essential to know which auto-configurations are applied to the application.

The following are three ways in which Spring Boot generates the auto-configuration report.

1. Application property approach

Set below property in application.properties or application.yml.

debug=true

2. Command-line approach

Or, if we don’t want to use the properties file approach, we can trigger the auto-configuration report by starting the application with the --debug switch.

java -jar <my_application>.jar --debug

Both the approaches above print the auto-configuration report on the console during startup. The third is an actuator-based approach that provides the auto-configuration report whenever we need it for diagnostic purposes.

3. Actuator approach

Another way to debug auto-configuration is to add a Spring Boot actuator to our project. Add below the dependency in POM.

<dependency>	
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

Add the property below into application.properties

management.endpoints.web.exposure.include=*

The /actuator/conditions endpoint will show the details of all the beans that are auto-configured, and those that are not.

Don’t worry too much about the actuator yet. We have separate bonus lessons to cover it.

Get hands-on with 1200+ tech skills courses.