Tag Archives: intellectual idea

[Solved] IDEA error: sun.security.pkcs not found

Abnormal scene

When Java 8 switches to Java 11, there is an error and sun is not found security 。

Problem analysis

Jar package and source code are available. The probability is due to the security policy in the new JDK.


In the compiler’s settings -> Build,Execution -> Compiler-> Disable in Java compiler:

Use ‘–release’ option for cross-compilation

Then rebuild

If there is no exception after build, check it again.

[Solved] IDEA try-with-resources Error: AutoCloseable

IDEA try-with-resources error: AutoCloseable

try (HttpPost post = new HttpPost(url)){
}catch(... | ... ){

Editor tip: incompatible types: try with resources is not applicable to variable types

Reason: the httppost used does not implement closeable and is not supported. The compiler automatically helps us complete close(), which is not available in httppost. If you want to test the writing method, you can use: closeablehttpclient, bufferedinputstream and so on. Finally, decompile it.

try (CloseableHttpClient client =HttpClients.createDefault();){

serviceimpl inherits generic public impl startup error: ClassCastException (Mybatis-plus version Issue)

Project scenario:

Mybatis plus version: 3.4.3
create abstract general services for service classes and service implementation classes

service port: service extends AbstracService<T>
service: serviceimpl extends  AbstracServiceImpl<M,T> implements service 
Abstract Common Service Interface: AbstracService<T extends xxBaseEntity> extends IService<T>
Abstract Common Service Interface Implementation: AbstracServiceImpl<M extends BaseMapper<T>,T extends xxBaseEntity> extends ServiceImpl<M, T> implements AbstracService<T>

Problem Description.
Startup error message:
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [cn.xx.xx.xx.service.impl.ServiceImpl]: Constructor threw exception; nested exception is java.lang.ClassCastException: sun.reflect.generics.reflectiveObjects.TypeVariableImpl cannot be cast to java.lang.Class
at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:224)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:87)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1326)
… 157 common frames omitted
Caused by: java.lang.ClassCastException: sun.reflect.generics.reflectiveObjects.TypeVariableImpl cannot be cast to java.lang.Class
at com.baomidou.mybatisplus.extension.service.impl.ServiceImpl.currentModelClass(ServiceImpl.java:88)
at com.baomidou.mybatisplus.extension.service.impl.ServiceImpl.(ServiceImpl.java:62)
at cn.lztl.assp.mall.service.impl.AbstractPromotionsServiceImpl.(AbstractPromotionsServiceImpl.java:38)
at cn.lztl.assp.mall.service.impl.ServiceImpl.(SeckillServiceImpl.java:51)
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 org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:211)
… 159 common frames omitted

Update mybatis-plus version to version or later.
Introduce dependency com.baomidou.mybatisplus.extension section must be version onwards

[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


    <!--Configure resources in build, to prevent our resource export from failing-->

[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] IDEA: Internal error (java.lang.UnsupportedClassVersionError)

After creating a spark project and testing a “hello word”, I encountered the following error:

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


Solution: Close the Erlang plugin and restart IDEA
Steps: Intel iJ IDEA -> Preferences -> Pluglinis -> (search Erlang) Remove the checkbox


[Solved] Spring Boot Startup Error: Failed to load property source from location ‘classpath:/application-dev.yml‘

Application.yml file format problem

If your project has no configuration errors and the configuration file name is normal, and you still have this problem, it must be a problem with the encoding of your yml file.

Because the encoding format of this file is GBK, the encoding format of the project is UTF-8, there are comments in it, and the comments are garbled, which leads to compilation failure.


IDEA open path: File –> Settings –> File Encodings, then change the format of /application.yml to the same as the project, i.e.: UTF-8.
To be on the safe side, change “Project Encoding” to UTF-8 as well.
Restart IDEA, then start the project, OK.

Translated with www.DeepL.com/Translator (free version)

Vue Browser Error: Failed to load resource: the server responded with a status of 404 (Not Found)

When you create a maven project in idea and use Vue to modify the content in HTML, you find that the HTML page is not modified successfully. F12 opens the background and displays an error: failed to load resource: the server responded with a status of 404 (not found). The browser does not find Vue JS file
(1) maven project to introduce vue.js file after the project needs to be packaged, double-click the package button.

(2) Since the vue.js file is stored in a static resource, check whether the project’s configuration file springMVC.xml opens access to the static resource.

After completing the above steps, the browser F12 background shows that vue.js was successfully fetched and the page content was successfully modified!

[Solved] Error creating bean with name ‘mvcContentNegotiationManager‘: Lookup method resolution failed

Recently, I encountered various strange exceptions when I used idea to build an aggregation project. Here is an exception reported by the operation of its sub module:

The prompt of exception information is:

Error creating bean with name ‘mvcContentNegotiationManager’: Lookup method resolution failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [org.springframework.web.accept.ContentNegotiationManagerFactoryBean] from ClassLoader [sun.misc.Launcher$ [email protected] ]

Solution 1:

Check whether the POM file of the sub module depends on the parent class. Of course, many people will find that when wearing the submodule, the POM file of the sub module will automatically depend on the parent class (as shown in the figure below)

If the dependency in the above figure is not automatically generated after inspection, and you have the same exception as me, then the parent project dependency is added to solve the exception with a high probability

After consulting relevant posts on the Internet and repeated experiments for many times, I found that:

This bug is because we created a module with the same name before, and then we removed it. Then we automatically generate webapp module through the skeleton, so that the module generated by the skeleton will completely overwrite your original POM file!!!

Unfortunately, you need the parent project dependency to start the project, then you will have this bug!

The safest and most reliable solution to avoid problem reproduction: check the dependency of POM file every time you create a sub module. If not, solve it manually

Of course, there are various online solutions, but I have tried and found that it can temporarily solve the problem, but it will still be overwritten the next time I use the skeleton to generate a module with the same name

Solution 2 (slightly reliable):

Setting — build — Maven — ignored files, cancel the ignored POM file, and the parent project dependency will be automatically added!


The root cause is that we have created modules with the same name before, but they are not really removed There is still a lot of information about deleting modules in the idea, so when creating a new module, the idea will automatically ignore the new module with the same name we wrote

Of course, a large part of the impact is because we use automatic skeleton generation!