Since spring boot's convention over configuration makes assumptions with AutoConfiguration, it sometimes can be difficult troubleshooting what is turned on or turned off. This episode will show how to display a listing of configurations enabled within your application.
Detailed Video Notes
Hey everyone this is Justin at level up lunch. If you are new to spring boot, AutoConfiguration classes are the smart classes that attempt to look at your class path and enable features or beans. For instance, if you want to enable metrics within spring-boot-actuator the MetricFilterAutoConfiguration will record servlet interactions. Spring boot folks try to do it right with AutoConfigrations but there maybe cases where you want to determine what is turned on or figure where an issue has occurred.
We haven't changed any classes that were created from the spring starter project so if we run the base project you will see in the console output spring-boot-actuator provides an endpoint /autoconfig. This endpoint which is mapped to AutoConfigurationReportEndpoint returns a json representation of positiveMatches and negativeMatches. Navigating to http://localhost:8080/autoconfig you should see output similar below:
The second way is to add a -Ddebug to your system properties. If you are running it locally within an IDE you can modify your system properties run as -> run configurations -> VM arguments you can add -Ddebug. Once you run this it looks a little bit different than json as it creates an auto configuration report within your console.
Similar to method #2 above, the third way would be adding --debug to the command line. Running in eclipse if we navigation to run as -> run configurations -> program arguments -> and add --debug this will show the auto-configration report. This also should work if you are running within the maven command line.
We showed a few ways you can determine which AutoConfiguration is enabled in hopes to help you debug your spring boot application. Hope you enjoyed and thanks for joining in today's level up lunch.