Example & Tutorial understanding programming in easy ways.

How to disable specific auto-configuration in spring boot?

We can use the exclude attribute of @EnableAutoConfiguration to disable them, as shown in the following example:
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, we can use the excludeName attribute of the annotation and specify the fully qualified name instead. Finally, we can also control the list of auto-configuration classes to exclude by using the spring.autoconfigure.exclude property.

We can use exclude property as shown below to disable specific auto configuration

@EnableAutoConfiguration(exclude={OurClasssName.class})



Read More →