谷粒商城:java.sql.SQLException: The server time zone value ‘�й���׼ʱ��‘ is unrecognized

问题: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.
原因:
spring-boot-starter-parent 1.5.9.RELEASE和2.2.1.RELEASE依赖的mysql-connect-java的版本不同。2.2.1版本的mysql-connect的版本超过6.0。
解决办法一:
针对超过6.0的版本。配置application.yml的文件,有几点不同:

  1. datasource.driver-class不是com.mysql.jdbc.Driver而是com.mysql.cj.jdbc.Driver.
  2. 在url后面添加servertime
spring:
  datasource:
    driver-class-name: com.mysql.cj.jdbc.Driver
    url: jdbc:mysql://:3306/guli_pms?useUnicode=true&characterEncoding=utf-8&serverTimezone=Asia/Shanghai
    

解决办法二:
将mysql-connect的版本重新设置低于6.0版本

<properties>
		<java.version>1.8</java.version>
		<spring-cloud.version>Hoxton.SR6</spring-cloud.version>
		<mysql.version>5.1.46</mysql.version>
	</properties>

你可能感兴趣的:(谷粒商城:java.sql.SQLException: The server time zone value ‘�й���׼ʱ��‘ is unrecognized)