场景:
Spring Boot配置MySQL数据源时报错: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: datasource: username: root password: root url: jdbc:mysql://127.0.0.1:3306/spring-boot-learn driver-class-name: com.mysql.cj.jdbc.Driver type: com.mysql.cj.jdbc.MysqlConnectionPoolDataSource
正确的配置
spring: datasource: username: root password: root url: jdbc:mysql://127.0.0.1:3306/spring-boot-learn?serverTimezone=UTC driver-class-name: com.mysql.cj.jdbc.Driver type: com.mysql.cj.jdbc.MysqlConnectionPoolDataSource