maven(mvc)连接MySQL报错[Caused by: com.mysql.cj.exceptions.InvalidConnectionAttributeException: The se]
程序员文章站
2022-04-04 20:53:37
...
原因分析(MySQL8.0以后出现的问题)
Caused by: com.mysql.cj.exceptions.InvalidConnectionAttributeException: 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.
原因:com.mysql.cj网站.exceptions.InvalidConnectionAttributeException:服务器时区值’�й���ʱ��’。如果要利用时区支持,则必须配置服务器或JDBC驱动程序(通过serverTimezone配置属性)以使用更具体的时区值。
解决方法
将原来的配置
<property name="url" value="jdbc:mysql://localhost:3306/spring"/>
改为(加上时区)
<property name="url" value="jdbc:mysql://localhost:3306/spring?serverTimezone=GMT%2B8"/>