问题描述:
新建的springboot项目启动报错Failed to configure a DataSource: ‘url’ attribute is not specified and no embedded datasource could be configured.
完整版报错信息:
原因分析:
Failed to configure a DataSource: ‘url’ attribute is not specified and no embedded datasource could be configured.
这句话翻译后的意思就是:
无法配置datasource,未指定url属性,也无法嵌入数据源。
这个错误的原因是你在你的springboot的项目中没有配置datasource相关的一些属性,例如:地址值,数据库驱动,用户名,密码等。
解决方案:
解决方法有两种:
1⃣️去spingboot的配置文件下将这些配置一一配好。
2⃣️ 将springboot启动类的头部注解改为:
@SpringBootApplication(exclude= {DataSourceAutoConfiguration.class})
再次启动springboot,发现启动成功。没有之前的错误 。