1.

What is an auto-configuration?

Answer»

SPRING boot autoconfiguration, check what are the jars that are AVAILABLE in the classpath, according to that autoconfiguration provides a basic configuration to the application according to that jars or library available.

  • Spring Boot autoconfigurator is used by Spring Boot Framework to provide “Auto-Configuration”.
  • Auto-configuration solves the problem of doing amount of configuration in Spring framework, it detects the dependency in a pom.xml file and according to that it CONFIGURES the spring boot application.
  • Below is the key annotation which we need to use to enable autoconfiguration

@EnableAutoConfiguration

  • We have a below option to enable the specific class to autoconfigure with the existing application.

@ConditionalOnClass({ DataSource.class, EmbeddedDatabaseType.class })

  • If we need to enable the external properties file, we can use the below annotation.

@EnableConfigurationProperties(MySQLDataSourceProperties.class)

  • Below annotation works when there is no bean available in the class PATH than its configure with configure bean class.

@ConditionalOnMissingBean

Spring boot autoconfiguration brings certain level of intelligence into the application so that it removes the hurdles to provide the configuration manually. ONE can debug the spring boot application by using the below approach:

  • Switch on the debug logging
  • Trigger the spring boot actuator 


Discussion

No Comment Found