16.2 Disabling specific auto-configuration
If you find that specific auto-configure classes are being applied that you don’t want, you can use the exclude attribute of @EnableAutoConfiguration to disable them.
import org.springframework.boot.autoconfigure.*;
import org.springframework.boot.autoconfigure.jdbc.*;
import org.springframework.context.annotation.*;
_@Configuration_
_@EnableAutoConfiguration(exclude={DataSourceAutoConfiguration.class})_
public class MyConfiguration {
}
If the class is not on the classpath, you can use the excludeName attribute of the annotation and specify the fully qualified name instead. Finally, you can also control the list of auto-configuration classes to exclude via the spring.autoconfigure.exclude property.
![]() |
Tip |
|---|---|
| You can define exclusions both at the annotation level and using the property. |
![[Tip]](Spring Boot Reference Guide_files/tip.png)