SpringBoot连接数据库时报:The server time zone value ‘�й���׼ʱ��‘ is unrecognized or represents more than

当我们在使用springboot启动项目时报:

Could not obtain connection to query metadata : 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.

是因为我们在连接数据库时application.properties没有创建serverTimezone:
SpringBoot连接数据库时报:The server time zone value ‘�й���׼ʱ��‘ is unrecognized or represents more than_第1张图片
解决办法在application.properties文件中的spring.datasource.url添加serverTimezone即可:

spring.datasource.url=jdbc:mysql://localhost:3306/db_book_system?serverTimezone=GMT&characterEncoding=utf-8

SpringBoot连接数据库时报:The server time zone value ‘�й���׼ʱ��‘ is unrecognized or represents more than_第2张图片

你可能感兴趣的:(java报错汇总)