SpringBoot连接MySQL数据库时,报了以下错误:
`org.springframework.jdbc.CannotGetJdbcConnectionException: Failed to obtain JDBC Connection; nested exception is 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
原因是报了服务 时区的错误。
解决方法:
在application.yml或者application.properties文件中,数据库连接的URL路径后面加上 serverTimezone=UTC 即可
url: jdbc:mysql://localhost:3306/travel?useUnicode=true&characterEncoding=utf8&serverTimezone=UTC