引言:在springboot项目启动时报错,failed to configure a dataSource 'url' attribute is not specified and no embeded datasource could be configured.if you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
解决:
可能疑惑,项目中在application.properties或者application.yml明明配置了数据库url为啥还报这种错,原因是没有把配置文件标记成resources root目录。右键resources目录,mark as就好,mark后原sources目录本身是文件夹图标会变成resources图标,再运行试试吧!
其他情况解决方案:
1.不需要连接数据库,只是搭建了空壳的测试项目,没有配置数据库账号密码,两种解决:
a)启动类添加注解:
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)
b)删除pom中数据库相关的jar,比如jdbc;
Do i explain it clearly to you?Hope to help you,ths!