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

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐