SpringBoot 中怎么禁用某些自动配置特性?

2023-05-16

有 3 种方法。如果我们想禁用某些自动配置特性,可以使用 @EnableAutoConfiguration 或 @SpringBootApplication 注解的 exclude 属性来指明。

// 方案1,下面的代码段是使 DataSourceAutoConfiguration 无效:
@EnableAutoConfiguration(exclude = DataSourceAutoConfiguration.class)
public class MyConfiguration {}
// 方案2
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
public class MyConfiguration { }
// 方案3,在配置文件中配置
spring.autoconfigure.exclude=org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration

使用 SpringBoot 如何自定义一个 starter? 

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

SpringBoot 中怎么禁用某些自动配置特性? 的相关文章

随机推荐

  • 构建ApplicationContext层次结构(添加父上下文或根上下文)

    目录 官网文档 71 4 Build an ApplicationContext hierarchy adding a parent or root context 翻译 71 4 构建ApplicationContext层次结构 xff0
  • 创建非Web应用程序

    目录 官方文档 71 5 Create a non web application 翻译 71 5 创建非Web应用程序 官方文档 71 5 Create a non web application Not all Spring appli
  • Customizing the Banner

    自定义方式 1 设置banner txt文件 默认读取根路径 xff0c 也可以通过banner location属性指定文件位置 xff0c 并且可以通过banner charset 默认是UTF 8 属性设置txt文件编码 在banne
  • isAssignableFrom方法浅析

    源码 Determines if the class or interface represented by this 64 code Class object is either the same as or is a superclas
  • @SuppressWarnings("serial")

    比如有个类实现了java io Serialize接口 xff1a package com onede4 test public class TestSerial implements java io Serializable 如果代码仅仅
  • angularJs中将字符串转换为HTML格式

    首先定义一个filter xff1a filter 39 to trusted 39 39 sce 39 function sce return function text return sce trustAsHtml text 2 htm
  • 如何在IDEA启动多个Spring Boot工程实例

    目录 只需要三步走即可 在IDEA上点击Application右边的下三角 弹出选项后 xff0c 点击Edit Configuration 打开配置后 xff0c 将默认的Single instance only 单实例 的钩去掉 通过修
  • springboot学习记录一

    概述 Spring Boot可以轻松创建独立的 xff0c 生产级的基于Spring的应用程序 xff0c 您可以 只要运行 我们对Spring平台和第三方库采取了自以为是 武断 的观点 xff0c 因此您可以最少的手忙脚乱 慌乱 开始 大
  • Java8 如何正确使用 Optional

    引用 http www importnew com 26066 html Optional是Java8提供的为了解决null安全问题的一个API 善用Optional可以使我们代码中很多繁琐 丑陋的设计变得十分优雅 这篇文章是建立在你对Op
  • git清除本地账户

    删除保存在本地的git账户 git credential manager uninstall 缓存账户 git config global credential helper wincred
  • 服务注册与发现eureka

    目录 eureka server pom xml文件添加依赖 启动类添加注解 64 EnableEurekaServer appication yml配置文件 访问界面 eureka client pom xml文件添加依赖 启动类添加注解
  • 服务消费者RestTemplate+Ribbon

    目录 简介 pom xml添加依赖 通过 64 LoadBalanced注解表明这个restRemplate开启负载均衡的功能 这样 restTemplate访问接口就可以实现负载均衡功能了 简介 spring cloud有两种服务调用方式
  • 服务消费者Feign

    Feign简介 Feign是一个声明式的伪Http客户端 xff0c 它使得写Http客户端变得更简单 使用Feign xff0c 只需要创建一个接口并注解 它具有可插拔的注解特性 xff0c 可使用Feign 注解和JAX RS注解 Fe
  • 熔断器Hystrix

    目录 概述 在ribbon使用断路器 断路器简介 添加依赖 启动类添加注解 64 EnableHystrix 方法上添加 64 HystrixCommand 关闭service hi服务 Feign中使用断路器 开启断路器功能 修改 64
  • Hystrix Dashboard (断路器:Hystrix 仪表盘)

    目录 pom xml添加依赖 启动类添加 64 EnableHystrixDashboard注解 浏览器访问 pom xml添加依赖 lt dependency gt lt groupId gt org springframework bo
  • nexus3私服搭建

    应用场景 maven库分为本地仓库和远程仓库 包括私服和中央仓库 xff09 公司自己设立 xff0c 只为公司内部共享使用 xff0c 同时减少外部访问和下载频率等 使用Nexus搭建私服 下载 官网链接 xff1a https www
  • Java多种方法实现等待所有子线程完成再继续执行

    简介 在现实世界中 xff0c 我们常常需要等待其它任务完成 xff0c 才能继续执行下一步 Java实现等待子线程完成再继续执行的方式很多 我们来一一查看一下 Thread的join方法 该方法是Thread提供的方法 xff0c 调用j
  • nexus3私服使用

    使用功能包括 代理中央仓库 Snapshot包的管理 Release包的管理 第三方Jar上传到Nexus上 从nexus下载依赖jar 代理中央仓库 只要在PMO文件中配置私服的地址即可 获取jar包信息走私服 xff0c 然后私服保存的
  • springboot开启的两种方式

    目录 继承spring boot starter parent项目 导入spring boot dependencies项目依赖 Spring Boot依赖注意点 属性覆盖只对继承有效 资源文件过滤问题 使用Spring Boot很简单 x
  • SpringBoot 中怎么禁用某些自动配置特性?

    有 3 种方法 如果我们想禁用某些自动配置特性 xff0c 可以使用 64 EnableAutoConfiguration 或 64 SpringBootApplication 注解的 exclude 属性来指明 方案1 xff0c 下面的