赞
踩
【日期】: 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 参数。(如图)
【总结】: 遇事不慌,成事易达。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。