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})