当前位置:   article > 正文

【BUG日记】【Maven】【SpringBoot】启动项目的时候,报错:If you want an embedded database (H2, HSQL or Derby)

if you want an embedded database (h2, hsql or derby), please put it on the c

【日期】: 2020/9/1

【问题】: 启动基于maven+springboot项目,报错:If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
在这里插入图片描述

【原因】: 因为有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 参数。(如图)
在这里插入图片描述

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


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

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/611561
推荐阅读
相关标签
  

闽ICP备14008679号