使用Spring Boot 2 的jdbc驱动引发的问题
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
运行程序时抛出异常:
Caused by: java.sql.SQLException: The server time zone value 'DST' 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.
解决办法:
在
jdbcUrl=jdbc:mysql://localhost:3306/demo
后面加上:
jdbcUrl=jdbc:mysql://localhost:3306/demo?serverTimezone=UTC
但如果你的jdbcUrl类似下面:
jdbcUrl=jdbc:mysql://localhost:3306/demo?serverTimezone=UTC&characterEncoding=utf-8
就是有多个params的时候需要以&分开,但&要改为& 如下:(这个我是在其他地方看到的, 在后来的使用中, 发现这样写似乎并没有什么用, 个人认为只用用 & 会更好一点, 如果有人尝试过还请在下方回复我一下)
jdbcUrl=jdbc:mysql://localhost:3306/demo?serverTimezone=UTC&characterEncoding=utf-8