springboot启动失败常见问题

  • 刚开始使用springboot连接mysql数据库,项目启动的时候报了一个错误
Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.

原因:现在很多定的教学视频都比较老,教学使用的mysql版本和你自己本地使用的版本不一致,新版本的mysql需要设置成 “com.mysql.cj.jdbc.Driver”,另外还需要增加一个参数 serverTimezone=UTC
参考文档:https://blog.csdn.net/weixin_43770545/article/details/90486809

  • 项目启动的时候报错,很显然数据库没有正常连接
java.sql.SQLException: Access denied for user ''@'localhost' (using password: NO)

我当时写的配置是,写的时候IDEA直接提示选了一个,单词没选对data-username 和 data-password,实际应该使用 username 和 password,主要还是没有记清楚配置。当作是一个教训吧。
错误的配置:

spring:
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://localhost:3306/blog?useUnicode=true&charseterEncoding=utf-8&serverTimezone=UTC
    data-username: root
    data-password: root

正确的配置

spring:
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://localhost:3306/blog?useUnicode=true&charseterEncoding=utf-8&serverTimezone=UTC
    username: root
    password: root
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值