@Configuration and Auto-Configuration in Spring Boot
What is Auto-Configuration
Auto-configuration in Spring Boot will automatically help you configure your Spring application dependencies based on the jar dependencies that you have added. This helps speed up development time in case you don't want to write any explicit configuration code.
For example, if you have the Spring Boot Redis Starter dependency included: Redis AutoConfigure, and you don't have an explicit Redis configuration configured by your Spring Boot application, then Spring Boot will attempt to auto configure one for you based on the available properties that are prefixed with spring.data.redis
.
You can check out more detail about what properties is taken from the application.properties file here.
It is to note that, auto-configuration in Spring Boot is considered to be "non-invasive", meaning, if you start to define your own configuration that replaces part of the auto-configuration, then the auto-configuration will not kick in.
If you would like to find out which part of auto-configuration is being applied, you can run your application with the --debug flag or put in debug=true
within the application.properties to generate a report on what auto-configuration is being used.