Error information :
2021-03-08 14:03:10.727 INFO 6568 --- [ main] o.s.s.concurrent.
ThreadPoolTaskExecutor: Initializing ExecutorService 'applicationTaskExecutor'
2021-03-08 14:03:11.266 INFO 6568 --- [ main] com.fh.UserApplicationTests :
Started UserApplicationTests in3.846 seconds (JVM running for 4.996) io.
jsonwebtoken.ExpiredJwtException: JWT expired at 2021-03-08T14:02:47+0800.
Current time: 2021-03-08T14:03:12+0800 at io.jsonwebtoken.impl.DefaultJwtParser.
parse(DefaultJwtParser.java:365) at io.jsonwebtoken.impl.DefaultJwtParser.parse(
DefaultJwtParser.java:458) at io.jsonwebtoken.impl.DefaultJwtParser.
parseClaimsJws(DefaultJwtParser.java:518) at com.fh.UserApplicationTests.jmToken
(UserApplicationTests.java:62) at sun.reflect.NativeMethodAccessorImpl.invoke0(
Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(
NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.
invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(
Method.java:498) at org.junit.platform.commons.util.ReflectionUtils.invokeMethod
(ReflectionUtils.java:686) at org.junit.jupiter.engine.execution.
MethodInvocation.proceed(MethodInvocation.java:60) at org.junit.jupiter.engine.
execution.InvocationInterceptorChain$ValidatingInvocation.proceed(
InvocationInterceptorChain.java:131) at org.junit.jupiter.engine.extension.
TimeoutExtension.intercept(TimeoutExtension.java:149) at org.junit.jupiter.
engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:
140) at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(
TimeoutExtension.java:84) at org.junit.jupiter.engine.execution.
ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(
ExecutableInvoker.java:115) at org.junit.jupiter.engine.execution.
ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105) at org.junit.
jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.
proceed(InvocationInterceptorChain.java:106) at org.junit.jupiter.engine.
execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)
at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke
(InvocationInterceptorChain.java:45) at org.junit.jupiter.engine.execution.
InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37) at org.
junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:
104) at org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(
ExecutableInvoker.java:98) at org.junit.jupiter.engine.descriptor.
TestMethodTestDescriptor.lambda$invokeTestMethod$6(TestMethodTestDescriptor.java
:212) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.
execute(ThrowableCollector.java:73) at org.junit.jupiter.engine.descriptor.
TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:208) at
org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(
TestMethodTestDescriptor.java:137) at org.junit.jupiter.engine.descriptor.
TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:71) at org.junit.
platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(
NodeTestTask.java:135) at org.junit.platform.engine.support.hierarchical.
ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.
engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(
NodeTestTask.java:125) at org.junit.platform.engine.support.hierarchical.Node.
around(Node.java:135) at org.junit.platform.engine.support.hierarchical.
NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123) at org.junit.
platform.engine.support.hierarchical.ThrowableCollector.execute(
ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.
NodeTestTask.executeRecursively(NodeTestTask.java:122) at org.junit.platform.
engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80) at java.
util.ArrayList.forEach(ArrayList.java:1257) at org.junit.platform.engine.support
.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(
SameThreadHierarchicalTestExecutorService.java:38) at org.junit.platform.engine.
support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:
139) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.
execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.
hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125) at
org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135) at org
.junit.platform.engine.support.hierarchical.NodeTestTask.
lambda$executeRecursively$8(NodeTestTask.java:123) token Value expired at org.junit.
platform.engine.support.hierarchical.ThrowableCollector.execute(
ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.
NodeTestTask.executeRecursively(NodeTestTask.java:122) at org.junit.platform.
engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80) at java.
util.ArrayList.forEach(ArrayList.java:1257) at org.junit.platform.engine.support
.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(
SameThreadHierarchicalTestExecutorService.java:38) at org.junit.platform.engine.
support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:
139) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.
execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.
hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125) at
org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135) at org
.junit.platform.engine.support.hierarchical.NodeTestTask.
lambda$executeRecursively$8(NodeTestTask.java:123) at org.junit.platform.engine.
support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at
org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(
NodeTestTask.java:122) at org.junit.platform.engine.support.hierarchical.
NodeTestTask.execute(NodeTestTask.java:80) at org.junit.platform.engine.support.
hierarchical.SameThreadHierarchicalTestExecutorService.submit(
SameThreadHierarchicalTestExecutorService.java:32) at org.junit.platform.engine.
support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.
java:57) at org.junit.platform.engine.support.hierarchical.
HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51) at org.junit.
platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:248) at org.
junit.platform.launcher.core.DefaultLauncher.lambda$execute$5(DefaultLauncher.
java:211) at org.junit.platform.launcher.core.DefaultLauncher.
withInterceptedStreams(DefaultLauncher.java:226) at org.junit.platform.launcher.
core.DefaultLauncher.execute(DefaultLauncher.java:199) at org.junit.platform.
launcher.core.DefaultLauncher.execute(DefaultLauncher.java:132) at com.intellij.
junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:74)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(
IdeaTestRunner.java:47) at com.intellij.rt.execution.junit.JUnitStarter.
prepareStreamsAndStart(JUnitStarter.java:242) at com.intellij.rt.execution.junit
.JUnitStarter.main(JUnitStarter.java:70) 2021-03-08 14:03:12.444 INFO 6568 --- [
extShutdownHook] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down
ExecutorService'applicationTaskExecutor'
Error information :
// visa , autograph String token=Jwts.builder() .setHeader(headerMap) .setClaims(payloadMap
) .setExpiration(new Date(endTime)) .signWith(SignatureAlgorithm.HS256,"rtet") .
compact(); System.out.println(token);
Change to : throw ExpiredJwtException abnormal
void createToken() { //token Divided into 3 part // The first part is what we call the head (header), //
The second part is called load (payload, Something similar to that carried on an airplane ), // The third part is visa (signature). // head Map<String,
Object> headerMap = new HashMap<String, Object>(); //HS256 Encryption mode headerMap.put(
"alg", "HS256"); headerMap.put("type", "JWT"); // Payload Map<String, Object>
payloadMap= new HashMap<String, Object>(); payloadMap.put("username", "lili");
payloadMap.put("userid", "432234443"); // Failure time long timeMillis = System.
currentTimeMillis(); // set up 1 minute long endTime = timeMillis + 60000; // visa , autograph String
token=null; try { token=Jwts.builder() .setHeader(headerMap) .setClaims(
payloadMap) .setExpiration(new Date(endTime)) .signWith(SignatureAlgorithm.HS256
,"rtet") .compact(); System.out.println(token); } catch (ExpiredJwtException e)
{ e.getClaims(); } System.out.println(token); }
Technology