【日期】: 2020/9/1

【问题】: 启动基于maven+springboot项目,报错:If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
【BUG日记】【Maven】【SpringBoot】启动项目的时候,报错:If you want an embedded database (H2, HSQL or Derby)

【原因】: 因为有pom文件的修改导致项目中增加的mysql、redis、es、mongodb的依赖包的导入,需要添加新的database配置文件,可能因为springboot的启动会自动加载这些依赖启动时候需要的以来文件。

Description:
Failed to configure a DataSource: ‘url’ attribute is not specified and no embedded datasource could be configured.
//无法配置数据库,没有指定url属性,并且无法配置embedded datasource
Reason: Failed to determine a suitable driver class
//原因:无法明确指定正确的驱动类(driver.class)
Action:
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).
//建议:
//如果如果需要加载嵌入式的数据库,请将他放入路径中
//如果有数据库设置需要从指定配置文件中加载,需要调用该配置文件(目前没有活动的配置文件)
 
 
参考地址:https://www.cnblogs.com/yourGod/p/9178515.html

【如何发现】: 百度查找,参考前辈的经验。1

【如何修复】: 两种办法,

一种注释掉pom相关的需要连接数据库的配置内容。(这里不做演示。)
第二种是在启动项目的那个主文件中,在注解里添加exclude = DataSourceAutoConfiguration.class 参数。(如图)
【BUG日记】【Maven】【SpringBoot】启动项目的时候,报错:If you want an embedded database (H2, HSQL or Derby)

【总结】: 遇事不慌,成事易达。


  1. Spring Boot相关组件的添加 ↩︎

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-08-08
  • 2021-08-29
  • 2022-12-23
  • 2021-07-14
  • 2021-05-11
  • 2021-07-31
猜你喜欢
  • 2022-12-23
  • 2021-05-20
  • 2021-05-13
  • 2021-06-11
相关资源
相似解决方案