Spring Boot关闭 DataSource/Redis 自动配置

2022-06-21 13:35:15

maven 子模块会继承父模块的包,但是在一些服务中我们不需要用到数据源,所以关掉spring boot 的自动配置。

关闭的方法有两种:

  • yaml /properties 配置
  • 注解关闭

yaml

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

注解

@SpringBootApplication(exclude={ DataSourceAutoConfiguration.class})
@SpringBootApplication(exclude={
		RedisAutoConfiguration.class,
		RedisRepositoriesAutoConfiguration.class})
  • 作者:昨夜我又梦见我去流浪
  • 原文链接:https://blog.csdn.net/qq_41076210/article/details/115127339
    更新时间:2022-06-21 13:35:15