zoukankan      html  css  js  c++  java
  • Spring Boot 排除自动配置的4个方法

    方法1

    使用 @SpringBootApplication 注解,用 exclude 属性进行排除指定的类:

    @SpringBootApplication(exclude = {DataSourceAutoConfiguration.class})
    public class Application {
        // ...
    }

    方法2

    单独使用 @EnableAutoConfiguration 注解的时候:

    @EnableAutoConfiguration(exclude = {DataSourceAutoConfiguration.class})
    public class Application {
        // ...
    }

    方法3

    使用 @SpringCloudApplication 注解的时候:

    @EnableAutoConfiguration(exclude = {DataSourceAutoConfiguration.class})
    @SpringCloudApplication
    public class Application {
        // ...
    }

    方法4

    终极方案,不管是 Spring Boot 还是 Spring Cloud 都可以搞定,在配置文件中指定参数 spring.autoconfigure.exclude 进行排除:

    spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration

    或者还可以这样写:

    spring.autoconfigure.exclude[0]=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration

    yml 配置文件:

    spring:     
      autoconfigure:
        exclude:
          - org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration
  • 相关阅读:
    python之函数对象、函数嵌套、名称空间与作用域、装饰器
    python之函数
    python基础-小练习
    python基础之文件操作
    python基础之字符编码
    web开发-Django博客系统
    HotSpot的算法实现
    垃圾回收机制(GC)
    Java注意点...
    JVM内存区域及对象
  • 原文地址:https://www.cnblogs.com/rinack/p/13225226.html
Copyright © 2011-2022 走看看