If we want to disable a specific auto-configuration in spring boot, we can exclude attribute of the @EnableAutoConfiguration annotation. See the following code snippet neutralizes DataSourceAutoConfiguration:
//annotations
@EnableAutoConfiguration(exclude = DataSourceAutoConfiguration.class)
public class MyConfiguration { }
//annotations
@EnableAutoConfiguration(exclude = DataSourceAutoConfiguration.class)
public class MyConfiguration { }
If we can enable auto-configuration with the @SpringBootApplication annotation. @SpringBootApplication annotation has @EnableAutoConfiguration as a meta-annotation. We could disable auto-configuration with an attribute of the same name:
//annotations
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
public class MyConfiguration { }
//annotations
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
public class MyConfiguration { }
We can also disable an auto-configuration with the spring.autoconfigure.exclude environment property. This configuration in the application.properties file does the same thing as before:
spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration