在使用springboot连接数据库启动项目出现错误:
Failed to configure a DataSource: 'url' attribute is not specified and no embedded datasource could
完整错误信息:
***************************
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).
- 在yml文件修改了正确的url后,在pom.xml中添加当前使用的mysql版本,即可成功运行。
spring:
datasource:
url: jdbc:mysql://localhost:3306/databasename?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=Asia/Shanghai&tinyInt1isBit=false
username: root
password: 010618
driver-class-name: com.mysql.cj.jdbc.Driver
2. 清理maven缓存:
在右侧边框栏选maven打开,按图示,先执行clean再install,即解决。