解决springboot启动项目url报错问题

在使用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).
  1. 在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,即解决。


版权声明:本文为weixin_45875257原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。