spring启动出现了以上错误,检查了下,在yml中正确配置了数据库信息,pom中依赖jar包都没有问题,感觉是<parent>依赖版本太低1.5.11.RELEASE,便更新到2.2.12.RELEASE
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.12.RELEASE</version>
</parent>
又变成了以下错误
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)
又检查了下依赖,做了2步操作:
1.mybatis-plus-boot-starter 跟 dynamic-datasource-spring-boot-starter 的版本保持一致,都是3.3.2,原来不一致
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>mybatis-plus-boot-starter</artifactId>
<version>3.3.2</version>
</dependency>
<dependency>
<groupId>com.baomidou</groupId>
<artifactId>dynamic-datasource-spring-boot-starter</artifactId>
<version>3.3.2</version>
</dependency>
2.增加了yaml依赖
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
<version>1.25</version>
</dependency>
重新编译后,启动正常。