java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ 解决方案

用IDEA 使用最新的springboot版本搭建应用时,pom.xml部分依赖如下:

		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>2.1.2.RELEASE</version>
		......
<!--mysql jdbc 连接驱动-->
		<dependency>
			<groupId>mysql</groupId>
			<artifactId>mysql-connector-java</artifactId>
		</dependency>

我们看到的是mysql连接器版本是:mysql-connector-java-8.0.13.jar。
启动服务运行时发下如下异常:

java.sql.SQLException: The server time zone value ‘Öйú±ê׼ʱ¼ä’ is unrecognized or represents more than one time

需要指定时区: ?serverTimezone=GMT%2B8即可GMT%2B8代表: 东八区

spring:
  application:
    name: cruncher
  datasource:
    driverClassName: com.mysql.jdbc.Driver
    url: jdbc:mysql://localhost:3306/spCloudDb

改为:

spring:
  application:
    name: cruncher
  datasource:
    driverClassName: com.mysql.jdbc.Driver
    url: "jdbc:mysql://localhost:3306/spCloudDb?serverTimezone=GMT%2B8"
posted @ 2019-02-15 14:37  IT当时语_青山师  阅读(14)  评论(0)    收藏  举报  来源