在启动springboot项目时,出现了数据库连接错误,如下:
java.sql.SQLException: The server time zone value '?й???????' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc time zone value if you want to utilize time zone support.
出现这种问题还是当前版本更新,与其他版本不兼容造成的问题,异常显示新版本的数据库连接程序需要指定UTC
时区
改正方法:
将配置文件中的url
后面加上指定的时区 serverTimezone=GMT
,将其值改为:
修改前:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/db?useSSL=false&useUnicode=true&characterEncoding=UTF-8
username: root
password: root
修改后:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/db?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=GMT
username: root
password: root
评论区