mysql-connector-java版本过高问题
框架:spring-boot+mybatis
编译后运行:
Loading class `com.mysql.jdbc.Driver'. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
进入列表页面:
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 specific time zone value if you want to utilize time zone support.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:1.8.0_131]
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:1.8.0_131]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_131]
at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[na:1.8.0_131]
解决方法①:
更改propertie.yml中的mysql的
driver-class-name: com.mysql.cj.jdbc.Driver
重新启动进入列表页面:依旧报错
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 specific time zone value if you want to utilize time zone support.
at sun.reflect.GeneratedConstructorAccessor29.newInstance(Unknown Source) ~[na:na]
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:1.8.0_131]
at java.lang.reflect.Constructor.newInstance(Constructor.java:423) ~[na:1.8.0_131]
解决方法②:
更改propertie.yml中的mysql的
url: jdbc:mysql://localhost:3306/maven?serverTimezone=UTC
运行正常!
一劳永逸解决方法:
添加版本号即可
问题描述:
这是由于数据库和系统时区差异所造成的,没有指定MySQL驱动版本的情况下它自动依赖的驱动是8.0.22的的版本
此问题为时区问题,在 JDBC 的连接 url 部分加上 serverTimezone=UTC 即可。
如果选择utc会比中国时间早8个小时,如果在中国,可以选择Asia/Shanghai或者Asia/Hongkong
easypeasy!


浙公网安备 33010602011771号