记录每一次报错
错误信息
2023-08-15 20:11:08.481 ERROR 18752 --- [eate-1940844413] com.alibaba.druid.pool.DruidDataSource : create connection SQLException, url: jdbc:mysql://localhost:3306/db_health?useSSL=false&serverTimezone=GNT%2B8&characterEncoding=UTF8&useUnicode=true, errorCode 0, state 08001
错误提示
java.sql.SQLNonTransientConnectionException: Could not create connection to database server.
......
Caused by: java.time.zone.ZoneRulesException: Unknown time-zone ID: GNT+8
错误原因
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
# 写上一个参数 时区
url: jdbc:mysql://localhost:3306/db_health?useSSL=false&serverTimezone=GNT%2B8&characterEncoding=UTF8&useUnicode=true
username: root
password: 123456
type: com.alibaba.druid.pool.DruidDataSource
yml配置文件里面的时区,因为是手打的原因打错了,把GMT打成的GNT,导致的报错, 所以说配置文件该cv的就cv,能不手打就不手打
修改代码
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
# 写上一个参数 时区
url: jdbc:mysql://localhost:3306/db_health?useSSL=false&serverTimezone=GNT%2B8&characterEncoding=UTF8&useUnicode=true
username: root
password: 123456
type: com.alibaba.druid.pool.DruidDataSource
修改完就可以运行了.