前言
今天在使用JdbcTemplate创建表的时候总是报错:
Caused by: 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.
错误原因:
mysql连接的依赖包是高版本的情况下:
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>6.0.4</version>
</dependency>
解决方案:
`在配置datasource.url时不能简单的这样配:
<property name="url" value="jdbc:mysql://localhost:3306/spring>
正确配置:
<property name="url" value="jdbc:mysql://localhost:3306/spring?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC"/>
小结
感谢您的阅读~~