SpringBoot项目创建过程常见错误——(四)

 链接MySQL数据库报错: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.

SpringBoot项目创建过程常见错误——(四)_第1张图片

 在连接数据库的配置文件中,在URL后加上

?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC

 application.yml文件中MySQL配置:

spring:
  datasource:
    name: test  #数据库名
    url: jdbc:mysql://localhost:3306/test?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC #url
    username: root  #用户名
    password: 123456  #密码
    driver-class-name: com.mysql.jdbc.Driver  #数据库链接驱动

参考博客:

https://blog.csdn.net/m0_37435073/article/details/78832445

你可能感兴趣的:(SpringBoot)