Tag Archives: java
Springboot thymeleaf Error: Exception processing template “table/dynamic_table”: Error resolving template [common]…
1. Error reporting:
[THYMELEAF][http-nio-8080-exec-3] Exception processing template "table/dynamic_table": Error resolving template [common], template might not exist or might not be accessible by any of the configured Template Resolvers (template: "table/dynamic_table" - line 17, col 10)
2. Occurrence
An error is reported when thymeleaf introduces a public page
3. Reasons for error reporting
Original code:
<div th:replace="common :: #leftmenu"></div>
Error report caused by not adding a path
After modification:
<div th:replace="table/common :: #leftmenu"></div>
Jjwt error: ERROR 9856 — [nio-8083-exec-2] o.a.c.c. [. [. [. [/]. [dispatch server]
**
Solve jjwt generation error
**
recently, when learning springboot + JWT + Vue, an error occurred while generating JWT. The error code is as follows:
2022-01-07 11:17:32.335 ERROR 9856 --- [nio-8083-exec-2] o.a.c.c.C.[.[.[/].[dispatcherServlet] : Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Filter execution threw an exception] with root cause
java.lang.ClassNotFoundException: javax.xml.bind.DatatypeConverter
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) ~[na:na]
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) ~[na:na]
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520) ~[na:na]
at io.jsonwebtoken.impl.Base64Codec.decode(Base64Codec.java:26) ~[jjwt-0.9.1.jar:0.9.1]
at io.jsonwebtoken.impl.DefaultJwtBuilder.signWith(DefaultJwtBuilder.java:99) ~[jjwt-0.9.1.jar:0.9.1]
at com.okwind.utils.JwtUtils.generateToken(JwtUtils.java:31) ~[classes/:na]
at com.okwind.security.LoginSuccessHandler.onAuthenticationSuccess(LoginSuccessHandler.java:32) ~[classes/:na]
Analysis error code: at com okwind.utils.JwtUtils. Generatetoken (jwtutils.Java: 31) ~ [classes/: Na] knows that the error occurred in jwtutils Generatetoken (jwtutils.Java: 31) is on line 31 of the tool class.
26 return Jwts.builder()
27 .setHeaderParam("typ", "JWT")
28 .setSubject(username)
29 .setIssuedAt(nowDate)
30 .setExpiration(expireDate)
31 .signWith(SignatureAlgorithm.HS256, app_secret)
32 .compact();
It means that an exception occurred in generateToken() and it is related to SignatureAlgorithm.HS256.
after analysis, it is referenced:
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.9.1</version>
</dependency>
jjwt version 0.91 is not supported for new JDK versions. There are two solutions.
Method 1: jdk drops to below 11.
Method 2: keep the jdk version unchanged from the higher version and introduce in pom.xml.
<dependency>
<groupId>io.jsonwebtoken</groupId>
<artifactId>jjwt</artifactId>
<version>0.9.1</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.4.0-b180830.0359</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>3.0.0-M4</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>3.0.0-M4</version>
</dependency>
<dependency>
<groupId>javax.activation</groupId>
<artifactId>activation</artifactId>
<version>1.1.1</version>
</dependency>
So far, the problem is solved.
[Solved] ### Error building SqlSession. ### The error may exist in com/atguigu/dao/SysUserMapper.xml ### Caus
Error building SqlSession.
The error may exist in com/atguigu/dao/SysUserMapper.xml
Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: java.io.IOException: Could not find resource com/atguigu/dao/SysUserMapper.xml
In POM.XML
:
<build>
<!--Configure resources in build, to prevent our resource export from failing-->
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>true</filtering>
</resource>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>true</filtering>
</resource></resources>
</build>
[Solved] JSON parse error: Cannot construct instance of
JSON parse error: Cannot construct instance of `com.request.ApplyRequest$Detail` (although at least one Creator exists): can only instantiate non-static inner class by using default, no-argument constructor; nested exception is com.fasterxml.jackson.databind.exc.MismatchedInputException: Cannot construct instance of `com.request.ApplyRequest$Detail` (although at least one Creator exists): can only instantiate non-static inner class by using default, no-argument constructor\n at [Source: (PushbackInputStream); line: 8, column: 13] (through reference chain: com.request.ApplyRequest[\"detailList\"]->java.util.ArrayList[0])
The problem appears: can only instantiate non-static inner class by using default
When you declare an inner class as an attribute of the current class, you need to make the inner class static, otherwise it won’t be loaded during class loading!
Solution: Declare the inner class as static directly!
IDEA Compile Error: Error:java: Compilation failed: internal java compiler error
Error reporting diagram
Repair
How to Solve Error:java.io.InvalidClassException
Exception information:
Caused by:java. io. InvalidClassException: com. eastcom xxx. xxxxxx. bean. AlarmReq; local class incompatible: stream classdesc serialversionUID =8050743254081999660, local class seriaiversionuId = 6638111461888145730
Cause of exception:
when serializing objects, they will be stored in redis memory, and then through redistemplate getValueSerializer(). The deserialize () method deserializes the data to the bean object. If the current bean object changes, that is, if an attribute is added, the serialVersionUID will change.
Because the serialVersionUID of this class is generated by the JVM according to the class name and the hash value of its attributes during serialization. When the properties of the class change, the serialVersionUID will also change accordingly, resulting in an error when the serialVersionUID does not match when the old data in redis is deserialized.
Solution:
I. Add code before the error reporting class property
private static final long serialVersionUID = 8050743254081999660L;
Here the UID corresponds to the above stream classdesc serialversionUID
ii.Clear the redis data linked by the current service.Clear the redis data linked by the current service.
Error resolving template [index], template might not exist
Problem: error resolving template [index], template may not exist
Solution:
1. Check the project structure first and check whether the location of the static resource file is misplaced
2. Check if the thymeleaf dependency in pom.xml is imported correctly
At first, I only imported the following dependencies, but it reported an error
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
3. Change to the following, just download it again
<!-- thymeleaf -->
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf-spring5</artifactId>
</dependency>
<dependency>
<groupId>org.thymeleaf.extras</groupId>
<artifactId>thymeleaf-extras-java8time</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
[Solved] IDEA Startup Error: java: Internal error in the mapping processor
1. Error information
java: Internal error in the mapping processor: java.lang.NullPointerException at org.mapstruct.ap.internal.processor.DefaultVersionInformation.createManifestUrl(DefaultVersionInformation.java:180) at org.mapstruct.ap.internal.processor.DefaultVersionInformation.openManifest(DefaultVersionInformation.java:151) at org.mapstruct.ap.internal.processor.DefaultVersionInformation.getLibraryName(DefaultVersionInformation.java:127) at org.mapstruct.ap.internal.processor.DefaultVersionInformation.getCompiler(DefaultVersionInformation.java:120) at org.mapstruct.ap.internal.processor.DefaultVersionInformation.fromProcessingEnvironment(DefaultVersionInformation.java:98) at org.mapstruct.ap.internal.processor.DefaultModelElementProcessorContext.<init>(DefaultModelElementProcessorContext.java:59) at org.mapstruct.ap.MappingProcessor.processMapperElements(MappingProcessor.java:222) at org.mapstruct.ap.MappingProcessor.process(MappingProcessor.java:162) 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.jetbrains.jps.javac.APIWrappers$1.invoke(APIWrappers.java:255) at org.mapstruct.ap.MappingProcessor.process(Unknown Source) at com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:794) at com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:705) at com.sun.tools.javac.processing.JavacProcessingEnvironment.access$1800(JavacProcessingEnvironment.java:91) at com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1035) at com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1176) at com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1170) at com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:856) at com.sun.tools.javac.main.Main.compile(Main.java:523) at com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:129) at com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:138) at org.jetbrains.jps.javac.JavacMain.compile(JavacMain.java:231) at org.jetbrains.jps.incremental.java.JavaBuilder.lambda$compileJava$2(JavaBuilder.java:514) at org.jetbrains.jps.incremental.java.JavaBuilder.invokeJavac(JavaBuilder.java:560) at org.jetbrains.jps.incremental.java.JavaBuilder.compileJava(JavaBuilder.java:512) at org.jetbrains.jps.incremental.java.JavaBuilder.compile(JavaBuilder.java:355) at org.jetbrains.jps.incremental.java.JavaBuilder.doBuild(JavaBuilder.java:280) at org.jetbrains.jps.incremental.java.JavaBuilder.build(JavaBuilder.java:234) at org.jetbrains.jps.incremental.IncProjectBuilder.runModuleLevelBuilders(IncProjectBuilder.java:1464) at org.jetbrains.jps.incremental.IncProjectBuilder.runBuildersForChunk(IncProjectBuilder.java:1101) at org.jetbrains.jps.incremental.IncProjectBuilder.buildTargetsChunk(IncProjectBuilder.java:1247) at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunkIfAffected(IncProjectBuilder.java:1066) at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunks(IncProjectBuilder.java:832) at org.jetbrains.jps.incremental.IncProjectBuilder.runBuild(IncProjectBuilder.java:419) at org.jetbrains.jps.incremental.IncProjectBuilder.build(IncProjectBuilder.java:183) at org.jetbrains.jps.cmdline.BuildRunner.runBuild(BuildRunner.java:132) at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:301) at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:132) at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler.lambda$channelRead0$0(BuildMain.java:219) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)
2. Solutions
1. Set File→settings→Compiler’s User-local build process VM options (overrides Shared options) option to set -Djps.track.ap.dependencies=false, select apply
2. modify the version of mapstruct-processor in pom.xml and upgrade it to 1.4.1.Final or higher
Both methods can be tried, I was successful in the first method
[Solved] Eclipse Error: A JNI error has occurred, please check your installation and try again
Solution:
① Check whether the package name contains “Java” and modify it. Java should be avoided when creating the package.
② Run the Java version and javac version commands in CMD to check their own JDK and JRE versions. If they are different, reconfigure the environment variables to make them consistent
The above two steps can solve most of the problems. If they are still not solved, it is recommended to reinstall the JDK and reconfigure the environment variables.
[Solved] IDEA: Internal error (java.lang.UnsupportedClassVersionError)
Internal error (java.lang.UnsupportedClassVersionError): org/intellij/erlang/jps/model/JpsErlangModelSerializerExtension has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0 java.lang.UnsupportedClassVersionError: org/intellij/erlang/jps/model/JpsErlangModelSerializerExtension has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
Steps: Intel iJ IDEA -> Preferences -> Pluglinis -> (search Erlang) Remove the checkbox



[Solved] Error getting generated key or setting result to parameter object. UnsupportedOperationException
Mybatis batch inserts and returns the primary key to the original list
report errors
Error getting generated key or setting result to parameter object. UnsupportedOperationException
reason
The version before mybatis 3.3.1 does not support the function of batch adding and returning the primary key ID; Some versions after mybatis # 3.3.1 support batch insert return ID, but do not support multiple parameters of Dao layer batch insert function, @ param annotation; (that is, table splitting is not supported) mybatis versions after 3.5.1 support batch insertion, return ID, multiple parameters, and @ param annotation
Solution:
Upgrade mybatis 3.5.1 (and ensure that all mybatis versions that Maven depends on are greater than 3.5.1) Dao
void batchInsert(@Param("idx") Integer idx, @Param("list") List<DO> list);
mapper
<insert id="batchInsert" useGeneratedKeys="true" keyProperty="list.id">
insert into do_${idx} (name, address)
values
<foreach collection="list" item="item" separator=",">
(#{item.name},#{item.address})
</foreach>
</insert>
Note: because the function has multiple parameters, it is impossible to determine which parameter ID is taken, so it needs to indicate that it is list in keyproperty = “list.ID”.