今天在跑XXL-job的源码的时候报了一个错误
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.
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:61)
at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:85)
at com.mysql.cj.util.TimeUtil.getCanonicalTimezone(TimeUtil.java:132)
at com.mysql.cj.protocol.a.NativeProtocol.configureTimezone(NativeProtocol.java:2121)
at com.mysql.cj.protocol.a.NativeProtocol.initServerSession(NativeProtocol.java:2145)
at com.mysql.cj.jdbc.ConnectionImpl.initializePropsFromServer(ConnectionImpl.java:1310)
at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:967)
at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:826)
... 12 common frames omitted
这个一个看还是很明白的,就是说需要指定时区,但是在我印象里面,指定时区不是必要的操作啊,所以我还蛮懵逼的。后来查了下代码,才发现xxl-job的源码引入的mysql连接的包是8.X的,对于mysql8来说,增加了蛮多的的新特性的,这个就是一个。
解决方法蛮简单的就是在url上加上时区就行
serverTimezone=UTC
但是这样和国内的本地时间是有差值的,所以一般为了开发方便还是指定本地时区
serverTimezone=Asia/Shanghai
当然也可以降低版本还是用5.7X的版本