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
  • 相关阅读:
    Xshell 设置右键粘贴功能
    python中dict操作集合
    mac 设置网页字体
    博客收藏
    memcache 安装与简单使用
    mac安装homebrew
    Graphviz下载 使用
    jekyll 与hexo
    js 汉字排序
    初试gem
  • 原文地址:https://www.cnblogs.com/rinack/p/13225226.html
Copyright © 2011-2022 走看看