您的位置:首页 > 编程语言 > Java开发

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'com

2018-02-10 23:59 1211 查看
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘com

spring连接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.

at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:569)

at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:537)

at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:527)

at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:512)

at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:480)

at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:498)

at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:494)

at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:69)

at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:1634)

at com.mysql.cj.jdbc.ConnectionImpl.(ConnectionImpl.java:637)

at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:351)

at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:224)

at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1358)

at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1414)

at com.alibaba.druid.pool.DruidDataSource$CreateConnectionThread.run(DruidDataSource.java:1654)

Caused by: com.mysql.cj.core.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.

解决方案:

方案1、在项目代码-数据库连接URL后,加上

?serverTimezone=UTC



方案2、在mysql中设置时区,默认为SYSTEM

set global time_zone=’+8:00’

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐