主要错误:
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could be configured.
未能配置数据源:未指定“url”属性,也无法配置嵌入式数据源。
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2019-06-03 09:47:45.300 ERROR 23160 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
APPLICATION FAILED TO START
***************************
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).
由第一幅图知,最先发生错误的地方在创建datasource这个Bean,之后造成dao,service,controller都报错了
com.mysql.jdbc.Driver的版本太低,与springboot不兼容(springboot使用的2.3.2.RELEASE)
<!-- mysql驱动 --> <!-- 此版本太低--> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.18</version> </dependency>
更换以下依赖后正常了
<!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java --> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.21</version> </dependency>
总结:使用application.properties配置文件时springboot的2.3.2.RELEASE与mysql-connector-java的5.1.18不兼容
其他可能的原因,又看到这篇写的比较多,评论也多
查看:
https://blog.csdn.net/qq_40223688/article/details/88191732