问题:
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
:129) ~[mysql
-connector
-java
-8.0.21.jar
:8.0.21]
at com
.mysql
.cj
.jdbc
.exceptions
.SQLError
.createSQLException(SQLError
.java
:97) ~[mysql
-connector
-java
-8.0.21.jar
:8.0.21]
at com
.mysql
.cj
.jdbc
.exceptions
.SQLError
.createSQLException(SQLError
.java
:89) ~[mysql
-connector
-java
-8.0.21.jar
:8.0.21]
at com
.mysql
.cj
.jdbc
.exceptions
.SQLError
.createSQLException(SQLError
.java
:63) ~[mysql
-connector
-java
-8.0.21.jar
:8.0.21]
at com
.mysql
.cj
.jdbc
.exceptions
.SQLError
.createSQLException(SQLError
.java
:73) ~[mysql
-connector
-java
-8.0.21.jar
:8.0.21]
at com
.mysql
.cj
.jdbc
.exceptions
.SQLExceptionsMapping
.translateException(SQLExceptionsMapping
.java
:76) ~[mysql
-connector
-java
-8.0.21.jar
:8.0.21]
at com
.mysql
.cj
.jdbc
.ConnectionImpl
.createNewIO(ConnectionImpl
.java
:836) ~[mysql
-connector
-java
-8.0.21.jar
:8.0.21]
at com
.mysql
.cj
.jdbc
.ConnectionImpl
.<init>(ConnectionImpl
.java
:456) ~[mysql
-connector
-java
-8.0.21.jar
:8.0.21]
at com
.mysql
.cj
.jdbc
.ConnectionImpl
.getInstance(ConnectionImpl
.java
:246) ~[mysql
-connector
-java
-8.0.21.jar
:8.0.21]
at com
.mysql
.cj
.jdbc
.NonRegisteringDriver
.connect(NonRegisteringDriver
.java
:197) ~[mysql
-connector
-java
-8.0.21.jar
:8.0.21]
at com
.zaxxer
.hikari
.util
.DriverDataSource
.getConnection(DriverDataSource
.java
:138) ~[HikariCP
-3.4.5.jar
:na
]
at com
.zaxxer
.hikari
.pool
.PoolBase
.newConnection(PoolBase
.java
:358) ~[HikariCP
-3.4.5.jar
:na
]
at com
.zaxxer
.hikari
.pool
.PoolBase
.newPoolEntry(PoolBase
.java
:206) ~[HikariCP
-3.4.5.jar
:na
]
at com
.zaxxer
.hikari
.pool
.HikariPool
.createPoolEntry(HikariPool
.java
:477) [HikariCP
-3.4.5.jar
:na
]
at com
.zaxxer
.hikari
.pool
.HikariPool
.checkFailFast(HikariPool
.java
:560) [HikariCP
-3.4.5.jar
:na
]
at com
.zaxxer
.hikari
.pool
.HikariPool
.<init>(HikariPool
.java
:115) [HikariCP
-3.4.5.jar
:na
]
at com
.zaxxer
.hikari
.HikariDataSource
.getConnection(HikariDataSource
.java
:112) [HikariCP
-3.4.5.jar
:na
]
at com
.security
.service
.Experiment5ApplicationTests
.contextLoads(Experiment5ApplicationTests
.java
:25) [test
-classes
/:na
]
at sun
.reflect
.NativeMethodAccessorImpl
.invoke0(Native Method
) ~[na
:1.8.0]
at sun
.reflect
.NativeMethodAccessorImpl
.invoke(NativeMethodAccessorImpl
.java
:62) ~[na
:1.8.0]
at sun
.reflect
.DelegatingMethodAccessorImpl
.invoke(DelegatingMethodAccessorImpl
.java
:43) ~[na
:1.8.0]
at java
.lang
.reflect
.Method
.invoke(Method
.java
:483) ~[na
:1.8.0]
at org
.junit
.platform
.commons
.util
.ReflectionUtils
.invokeMethod(ReflectionUtils
.java
:686) [junit
-platform
-commons
-1.6.2.jar
:1.6.2]
at org
.junit
.jupiter
.engine
.execution
.MethodInvocation
.proceed(MethodInvocation
.java
:60) [junit
-jupiter
-engine
-5.6.2.jar
:5.6.2]
at org
.junit
.jupiter
.engine
.execution
.InvocationInterceptorChain$ValidatingInvocation
.proceed(InvocationInterceptorChain
.java
:131) [junit
-jupiter
-engine
-5.6.2.jar
:5.6.2]
at org
.junit
.jupiter
.engine
.extension
.TimeoutExtension
.intercept(TimeoutExtension
.java
:149) [junit
-jupiter
-engine
-5.6.2.jar
:5.6.2]
at org
.junit
.jupiter
.engine
.extension
.TimeoutExtension
.interceptTestableMethod(TimeoutExtension
.java
:140) [junit
-jupiter
-engine
-5.6.2.jar
:5.6.2]
at org
.junit
.jupiter
.engine
.extension
.TimeoutExtension
.interceptTestMethod(TimeoutExtension
.java
:84) [junit
-jupiter
-engine
-5.6.2.jar
:5.6.2]
at org
.junit
.jupiter
.engine
.descriptor
.TestMethodTestDescriptor$$Lambda$
151/1268959798.apply(Unknown Source
) [junit
-jupiter
-engine
-5.6.2.jar
:5.6.2]
at org
.junit
.jupiter
.engine
.execution
.ExecutableInvoker$ReflectiveInterceptorCall
.lambda$ofVoidMethod$
0(ExecutableInvoker
.java
:115) [junit
-jupiter
-engine
-5.6.2.jar
:5.6.2]
at org
.junit
.jupiter
.engine
.execution
.ExecutableInvoker$ReflectiveInterceptorCall$$Lambda$
152/928466577.apply(Unknown Source
) [junit
-jupiter
-engine
-5.6.2.jar
:5.6.2]
at org
.junit
.jupiter
.engine
.execution
.ExecutableInvoker
.lambda$invoke$
0(ExecutableInvoker
.java
:105) [junit
-jupiter
-engine
-5.6.2.jar
:5.6.2]
at org
.junit
.jupiter
.engine
.execution
.ExecutableInvoker$$Lambda$
376/2059572982.apply(Unknown Source
) [junit
-jupiter
-engine
-5.6.2.jar
:5.6.2]
at org
.junit
.jupiter
.engine
.execution
.InvocationInterceptorChain$InterceptedInvocation
.proceed(InvocationInterceptorChain
.java
:106) [junit
-jupiter
-engine
-5.6.2.jar
:5.6.2]
at org
.junit
.jupiter
.engine
.execution
.InvocationInterceptorChain
.proceed(InvocationInterceptorChain
.java
:64) [junit
-jupiter
-engine
-5.6.2.jar
:5.6.2]
at org
.junit
.jupiter
.engine
.execution
.InvocationInterceptorChain
.chainAndInvoke(InvocationInterceptorChain
.java
:45) [junit
-jupiter
-engine
-5.6.2.jar
:5.6.2]
at org
.junit
.jupiter
.engine
.execution
.InvocationInterceptorChain
.invoke(InvocationInterceptorChain
.java
:37) [junit
-jupiter
-engine
-5.6.2.jar
:5.6.2]
at org
.junit
.jupiter
.engine
.execution
.ExecutableInvoker
.invoke(ExecutableInvoker
.java
:104) [junit
-jupiter
-engine
-5.6.2.jar
:5.6.2]
at org
.junit
.jupiter
.engine
.execution
.ExecutableInvoker
.invoke(ExecutableInvoker
.java
:98) [junit
-jupiter
-engine
-5.6.2.jar
:5.6.2]
at org
.junit
.jupiter
.engine
.descriptor
.TestMethodTestDescriptor
.lambda$invokeTestMethod$
6(TestMethodTestDescriptor
.java
:212) [junit
-jupiter
-engine
-5.6.2.jar
:5.6.2]
at org
.junit
.jupiter
.engine
.descriptor
.TestMethodTestDescriptor$$Lambda$
810/2084041029.execute(Unknown Source
) [junit
-jupiter
-engine
-5.6.2.jar
:5.6.2]
at org
.junit
.platform
.engine
.support
.hierarchical
.ThrowableCollector
.execute(ThrowableCollector
.java
:73) [junit
-platform
-engine
-1.6.2.jar
:1.6.2]
at org
.junit
.jupiter
.engine
.descriptor
.TestMethodTestDescriptor
.invokeTestMethod(TestMethodTestDescriptor
.java
:208) [junit
-jupiter
-engine
-5.6.2.jar
:5.6.2]
at org
.junit
.jupiter
.engine
.descriptor
.TestMethodTestDescriptor
.execute(TestMethodTestDescriptor
.java
:137) [junit
-jupiter
-engine
-5.6.2.jar
:5.6.2]
at org
.junit
.jupiter
.engine
.descriptor
.TestMethodTestDescriptor
.execute(TestMethodTestDescriptor
.java
:71) [junit
-jupiter
-engine
-5.6.2.jar
:5.6.2]
at org
.junit
.platform
.engine
.support
.hierarchical
.NodeTestTask
.lambda$executeRecursively$
5(NodeTestTask
.java
:135) [junit
-platform
-engine
-1.6.2.jar
:1.6.2]
at org
.junit
.platform
.engine
.support
.hierarchical
.NodeTestTask$$Lambda$
248/1907431275.execute(Unknown Source
) [junit
-platform
-engine
-1.6.2.jar
:1.6.2]
at org
.junit
.platform
.engine
.support
.hierarchical
.ThrowableCollector
.execute(ThrowableCollector
.java
:73) [junit
-platform
-engine
-1.6.2.jar
:1.6.2]
at org
.junit
.platform
.engine
.support
.hierarchical
.NodeTestTask
.lambda$executeRecursively$
7(NodeTestTask
.java
:125) [junit
-platform
-engine
-1.6.2.jar
:1.6.2]
at org
.junit
.platform
.engine
.support
.hierarchical
.NodeTestTask$$Lambda$
247/1383524016.invoke(Unknown Source
) [junit
-platform
-engine
-1.6.2.jar
:1.6.2]
at org
.junit
.platform
.engine
.support
.hierarchical
.Node
.around(Node
.java
:135) [junit
-platform
-engine
-1.6.2.jar
:1.6.2]
at org
.junit
.platform
.engine
.support
.hierarchical
.NodeTestTask
.lambda$executeRecursively$
8(NodeTestTask
.java
:123) [junit
-platform
-engine
-1.6.2.jar
:1.6.2]
at org
.junit
.platform
.engine
.support
.hierarchical
.NodeTestTask$$Lambda$
246/373182087.execute(Unknown Source
) [junit
-platform
-engine
-1.6.2.jar
:1.6.2]
at org
.junit
.platform
.engine
.support
.hierarchical
.ThrowableCollector
.execute(ThrowableCollector
.java
:73) [junit
-platform
-engine
-1.6.2.jar
:1.6.2]
at org
.junit
.platform
.engine
.support
.hierarchical
.NodeTestTask
.executeRecursively(NodeTestTask
.java
:122) [junit
-platform
-engine
-1.6.2.jar
:1.6.2]
at org
.junit
.platform
.engine
.support
.hierarchical
.NodeTestTask
.execute(NodeTestTask
.java
:80) [junit
-platform
-engine
-1.6.2.jar
:1.6.2]
at org
.junit
.platform
.engine
.support
.hierarchical
.SameThreadHierarchicalTestExecutorService$$Lambda$
252/1374026904.accept(Unknown Source
) [junit
-platform
-engine
-1.6.2.jar
:1.6.2]
at java
.util
.ArrayList
.forEach(ArrayList
.java
:1234) [na
:1.8.0]
at org
.junit
.platform
.engine
.support
.hierarchical
.SameThreadHierarchicalTestExecutorService
.invokeAll(SameThreadHierarchicalTestExecutorService
.java
:38) [junit
-platform
-engine
-1.6.2.jar
:1.6.2]
at org
.junit
.platform
.engine
.support
.hierarchical
.NodeTestTask
.lambda$executeRecursively$
5(NodeTestTask
.java
:139) [junit
-platform
-engine
-1.6.2.jar
:1.6.2]
at org
.junit
.platform
.engine
.support
.hierarchical
.NodeTestTask$$Lambda$
248/1907431275.execute(Unknown Source
) [junit
-platform
-engine
-1.6.2.jar
:1.6.2]
at org
.junit
.platform
.engine
.support
.hierarchical
.ThrowableCollector
.execute(ThrowableCollector
.java
:73) [junit
-platform
-engine
-1.6.2.jar
:1.6.2]
at org
.junit
.platform
.engine
.support
.hierarchical
.NodeTestTask
.lambda$executeRecursively$
7(NodeTestTask
.java
:125) [junit
-platform
-engine
-1.6.2.jar
:1.6.2]
at org
.junit
.platform
.engine
.support
.hierarchical
.NodeTestTask$$Lambda$
247/1383524016.invoke(Unknown Source
) [junit
-platform
-engine
-1.6.2.jar
:1.6.2]
at org
.junit
.platform
.engine
.support
.hierarchical
.Node
.around(Node
.java
:135) [junit
-platform
-engine
-1.6.2.jar
:1.6.2]
at org
.junit
.platform
.engine
.support
.hierarchical
.NodeTestTask
.lambda$executeRecursively$
8(NodeTestTask
.java
:123) [junit
-platform
-engine
-1.6.2.jar
:1.6.2]
at org
.junit
.platform
.engine
.support
.hierarchical
.NodeTestTask$$Lambda$
246/373182087.execute(Unknown Source
) [junit
-platform
-engine
-1.6.2.jar
:1.6.2]
at org
.junit
.platform
.engine
.support
.hierarchical
.ThrowableCollector
.execute(ThrowableCollector
.java
:73) [junit
-platform
-engine
-1.6.2.jar
:1.6.2]
at org
.junit
.platform
.engine
.support
.hierarchical
.NodeTestTask
.executeRecursively(NodeTestTask
.java
:122) [junit
-platform
-engine
-1.6.2.jar
:1.6.2]
at org
.junit
.platform
.engine
.support
.hierarchical
.NodeTestTask
.execute(NodeTestTask
.java
:80) [junit
-platform
-engine
-1.6.2.jar
:1.6.2]
at org
.junit
.platform
.engine
.support
.hierarchical
.SameThreadHierarchicalTestExecutorService$$Lambda$
252/1374026904.accept(Unknown Source
) [junit
-platform
-engine
-1.6.2.jar
:1.6.2]
at java
.util
.ArrayList
.forEach(ArrayList
.java
:1234) [na
:1.8.0]
at org
.junit
.platform
.engine
.support
.hierarchical
.SameThreadHierarchicalTestExecutorService
.invokeAll(SameThreadHierarchicalTestExecutorService
.java
:38) [junit
-platform
-engine
-1.6.2.jar
:1.6.2]
at org
.junit
.platform
.engine
.support
.hierarchical
.NodeTestTask
.lambda$executeRecursively$
5(NodeTestTask
.java
:139) [junit
-platform
-engine
-1.6.2.jar
:1.6.2]
at org
.junit
.platform
.engine
.support
.hierarchical
.NodeTestTask$$Lambda$
248/1907431275.execute(Unknown Source
) [junit
-platform
-engine
-1.6.2.jar
:1.6.2]
at org
.junit
.platform
.engine
.support
.hierarchical
.ThrowableCollector
.execute(ThrowableCollector
.java
:73) [junit
-platform
-engine
-1.6.2.jar
:1.6.2]
at org
.junit
.platform
.engine
.support
.hierarchical
.NodeTestTask
.lambda$executeRecursively$
7(NodeTestTask
.java
:125) [junit
-platform
-engine
-1.6.2.jar
:1.6.2]
at org
.junit
.platform
.engine
.support
.hierarchical
.NodeTestTask$$Lambda$
247/1383524016.invoke(Unknown Source
) [junit
-platform
-engine
-1.6.2.jar
:1.6.2]
at org
.junit
.platform
.engine
.support
.hierarchical
.Node
.around(Node
.java
:135) [junit
-platform
-engine
-1.6.2.jar
:1.6.2]
at org
.junit
.platform
.engine
.support
.hierarchical
.NodeTestTask
.lambda$executeRecursively$
8(NodeTestTask
.java
:123) [junit
-platform
-engine
-1.6.2.jar
:1.6.2]
at org
.junit
.platform
.engine
.support
.hierarchical
.NodeTestTask$$Lambda$
246/373182087.execute(Unknown Source
) [junit
-platform
-engine
-1.6.2.jar
:1.6.2]
at org
.junit
.platform
.engine
.support
.hierarchical
.ThrowableCollector
.execute(ThrowableCollector
.java
:73) [junit
-platform
-engine
-1.6.2.jar
:1.6.2]
at org
.junit
.platform
.engine
.support
.hierarchical
.NodeTestTask
.executeRecursively(NodeTestTask
.java
:122) [junit
-platform
-engine
-1.6.2.jar
:1.6.2]
at org
.junit
.platform
.engine
.support
.hierarchical
.NodeTestTask
.execute(NodeTestTask
.java
:80) [junit
-platform
-engine
-1.6.2.jar
:1.6.2]
at org
.junit
.platform
.engine
.support
.hierarchical
.SameThreadHierarchicalTestExecutorService
.submit(SameThreadHierarchicalTestExecutorService
.java
:32) [junit
-platform
-engine
-1.6.2.jar
:1.6.2]
at org
.junit
.platform
.engine
.support
.hierarchical
.HierarchicalTestExecutor
.execute(HierarchicalTestExecutor
.java
:57) [junit
-platform
-engine
-1.6.2.jar
:1.6.2]
at org
.junit
.platform
.engine
.support
.hierarchical
.HierarchicalTestEngine
.execute(HierarchicalTestEngine
.java
:51) [junit
-platform
-engine
-1.6.2.jar
:1.6.2]
at org
.junit
.platform
.launcher
.core
.DefaultLauncher
.execute(DefaultLauncher
.java
:248) [junit
-platform
-launcher
-1.6.2.jar
:1.6.2]
at org
.junit
.platform
.launcher
.core
.DefaultLauncher
.lambda$execute$
5(DefaultLauncher
.java
:211) [junit
-platform
-launcher
-1.6.2.jar
:1.6.2]
at org
.junit
.platform
.launcher
.core
.DefaultLauncher$$Lambda$
181/1514840818.accept(Unknown Source
) [junit
-platform
-launcher
-1.6.2.jar
:1.6.2]
at org
.junit
.platform
.launcher
.core
.DefaultLauncher
.withInterceptedStreams(DefaultLauncher
.java
:226) [junit
-platform
-launcher
-1.6.2.jar
:1.6.2]
at org
.junit
.platform
.launcher
.core
.DefaultLauncher
.execute(DefaultLauncher
.java
:199) [junit
-platform
-launcher
-1.6.2.jar
:1.6.2]
at org
.junit
.platform
.launcher
.core
.DefaultLauncher
.execute(DefaultLauncher
.java
:132) [junit
-platform
-launcher
-1.6.2.jar
:1.6.2]
at com
.intellij
.junit5
.JUnit5IdeaTestRunner
.startRunnerWithArgs(JUnit5IdeaTestRunner
.java
:69) [junit5
-rt
.jar
:na
]
at com
.intellij
.rt
.junit
.IdeaTestRunner$Repeater
.startRunnerWithArgs(IdeaTestRunner
.java
:33) [junit
-rt
.jar
:na
]
at com
.intellij
.rt
.junit
.JUnitStarter
.prepareStreamsAndStart(JUnitStarter
.java
:230) [junit
-rt
.jar
:na
]
at com
.intellij
.rt
.junit
.JUnitStarter
.main(JUnitStarter
.java
:58) [junit
-rt
.jar
:na
]
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
) ~[na
:1.8.0]
at sun
.reflect
.NativeConstructorAccessorImpl
.newInstance(NativeConstructorAccessorImpl
.java
:62) ~[na
:1.8.0]
at sun
.reflect
.DelegatingConstructorAccessorImpl
.newInstance(DelegatingConstructorAccessorImpl
.java
:45) ~[na
:1.8.0]
at java
.lang
.reflect
.Constructor
.newInstance(Constructor
.java
:408) ~[na
:1.8.0]
at com
.mysql
.cj
.exceptions
.ExceptionFactory
.createException(ExceptionFactory
.java
:61) ~[mysql
-connector
-java
-8.0.21.jar
:8.0.21]
at com
.mysql
.cj
.exceptions
.ExceptionFactory
.createException(ExceptionFactory
.java
:85) ~[mysql
-connector
-java
-8.0.21.jar
:8.0.21]
at com
.mysql
.cj
.util
.TimeUtil
.getCanonicalTimezone(TimeUtil
.java
:132) ~[mysql
-connector
-java
-8.0.21.jar
:8.0.21]
at com
.mysql
.cj
.protocol
.a
.NativeProtocol
.configureTimezone(NativeProtocol
.java
:2120) ~[mysql
-connector
-java
-8.0.21.jar
:8.0.21]
at com
.mysql
.cj
.protocol
.a
.NativeProtocol
.initServerSession(NativeProtocol
.java
:2143) ~[mysql
-connector
-java
-8.0.21.jar
:8.0.21]
at com
.mysql
.cj
.jdbc
.ConnectionImpl
.initializePropsFromServer(ConnectionImpl
.java
:1310) ~[mysql
-connector
-java
-8.0.21.jar
:8.0.21]
at com
.mysql
.cj
.jdbc
.ConnectionImpl
.connectOneTryOnly(ConnectionImpl
.java
:967) ~[mysql
-connector
-java
-8.0.21.jar
:8.0.21]
at com
.mysql
.cj
.jdbc
.ConnectionImpl
.createNewIO(ConnectionImpl
.java
:826) ~[mysql
-connector
-java
-8.0.21.jar
:8.0.21]
... 90 common frames omitted
原因:
使用了Mysql Connector/J 6.x以上的版本,然后就报了时区的错误
解决办法:
在jdbc后拼接serverTimezone=UTC 例:
spring
.datasource
.driver
-class-name
=com
.mysql
.jdbc
.Driver
spring
.datasource
.url
=jdbc
:mysql
://localhost
:3306/security
?characterEncoding
=UTF
-8&serverTimezone
=UTC
spring
.datasource
.username
=root
spring
.datasource
.password
=root