侧边栏壁纸
博主头像
王小木人

这是很长,很好的一生

  • 累计撰写 141 篇文章
  • 累计创建 43 个标签
  • 累计收到 7 条评论

目 录CONTENT

文章目录

exclude= {DataSourceAutoConfiguration.class} 失效 解决方案

王小木人
2022-06-07 / 0 评论 / 0 点赞 / 1,186 阅读 / 180 字

在引入了数据库相关依赖后就需要配置数据库相关的连接信息,否则就会报如下错误

Consider the following:
  If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
  If you have database settings to be loaded from a particular profile you may need to activate it (no profiles are currently active).

解决办法有两种 一是移除相关依赖 二是在启动类加上 exclude= {DataSourceAutoConfiguration.class} 注解忽略数据源相关信息加载

再使用 exclude= {DataSourceAutoConfiguration.class} 发现项目还是无法启动 那么可能是 项目中引入了其他依赖中使用到了数据库 例如 Druid 相关依赖

解决办法:
忽略中在增加

exclude= {
        DataSourceAutoConfiguration.class,
        DruidDataSourceAutoConfigure.class}
0

评论区