SpringBoot+Mybatis启动时报错,获取JDBC连接失败

报错信息如下:

There was an unexpected error (type=Internal Server Error, status=500).

nested exception is org.apache.ibatis.exceptions.PersistenceException: ### Error querying database. Cause: 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. ### The error may exist in file [F:\Java\ProTest\batdemo\target\classes\mapper\UserMapper.xml] ### The error may involve com.bat.dao.UserMapper.getAll ### The error occurred while executing a query ### Cause: 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.

解决办法:在数据库连接字符串后面加个配置

例如:

url: jdbc:mysql://localhost:3306/数据库名?serverTimezone=UTC

SpringBoot+Mybatis启动时报错,获取JDBC连接失败_第1张图片

 

 

你可能感兴趣的:(#,报错整理,Java)