If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.(个人笔记)

关于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).
//建议:
//如果如果需要加载嵌入式的数据库,请将他放入路径中
//如果有数据库设置需要从指定配置文件中加载,需要调用该配置文件(目前没有活动的配置文件)
 
Process finished with exit code 1

结合网上的很多种那些解决办法,都没什么用,最终自己这边是通过将resources下的配置文件直接复制一份丢到编译后的
target目录下的classes目录下

然后重启项目就正常了,但是不知道为什么好多人都说是在注解中排除springboot自动加载的数据源
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
个人觉得之所以报这样的错,就是springboot自动配置它没有加载到你自定义的配置文件里边的数据源,也就是你写的配置文件没有被读取,建议可以看下编译后你的target/classes目录下是不是有你写的配置文件

原文地址:https://www.cnblogs.com/kiki-study/p/13656086.html