解决SpringBoot关于DataSource的报错
错误信息
Description:
Failed to configure a DataSource: ‘url’ attribute is not specified and no embedded datasource could be configured.
Reason: Failed to determine a suitable 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).
解决思路
1. 查看mysql依赖
比如,数据库是高版本6~8的时候,就不能使用5.x的jar包版本
或者在项目中引入了mybatis、jdbc等jar包,却没有填写数据库连接信息
2. 查看target下是否有配置文件
如果不小心在Pom.xml文件中设置打包方式为pom,编译后,将在target/classes下找不到application.yml配置。也有可能是其它原因,所以这个检查很有必要
<packaging>pom</packaging>