在进行数据库配置时,碰到这两个报错问题,困扰了很久
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'initService' defined in file
和
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.
一开始以为是mysql配置的原因,翻来覆去的找相关博客,结果发现没有用,最后才知道,是因为maven依赖引进的mysql版本过高,idea不能自动兼容(应该是这样),最后就会报错。
翻译上述内容为:出现了mysql的无效连接属性异常:服务器时区值无法辨认或表示多个时区,如果你想使用时区支持,你必须通过服务器时区配置属性来配置服务器或JDBC驱动从而使用更具体的时区值。
解决方法:
在url后加上:
?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
亲测有效!!!!!!!!!!!!!!!