1

How to disable Spring Boot auto configuration.I want to disable the data source auto configuration.

1 Answer 1

2

Try this two way:

Properties configuration

    spring:
      profiles: app-profile
      autoconfigure:
        exclude:
        - org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
        - org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration
        

Class level configuration

    @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class})
    public class SpringBootApp {
    public static void main(String[] args) {
        SpringApplication.run(SpringBootApp.class, args);
    }

Reference:

https://docs.spring.io/spring-boot/docs/1.4.1.RELEASE/reference/html/using-boot-auto-configuration.html

1
  • If you could also include a link to general guide that would be great. +1 nevertheless Commented Dec 20, 2021 at 7:16

Not the answer you're looking for? Browse other questions tagged or ask your own question.