使用 Idea 进行 mvn 编译工作正常。
在 App.main 启动期间失败。
在 Ubuntu 上的其他 PC 上的旧 Idea 上运行良好。
环境:
Intellij 2020.3.2 作为管理员;
Java 15.02;
Windows 10 x64;
最新的地图结构。
如何解决这个问题?
D:\back\src\main\java\io\x\mapper\Mapper.java:15:8 java: Internal error in the mapping processor: java.lang.NullPointerException: Cannot invoke "java.net.URL.toExternalForm()" because "resource" is null
at org.mapstruct.ap.internal.processor.DefaultVersionInformation.createManifestUrl(DefaultVersionInformation.java:182)
at org.mapstruct.ap.internal.processor.DefaultVersionInformation.openManifest(DefaultVersionInformation.java:153)
at org.mapstruct.ap.internal.processor.DefaultVersionInformation.getLibraryName(DefaultVersionInformation.java:129)
at org.mapstruct.ap.internal.processor.DefaultVersionInformation.getCompiler(DefaultVersionInformation.java:122)
at org.mapstruct.ap.internal.processor.DefaultVersionInformation.fromProcessingEnvironment(DefaultVersionInformation.java:95)
at org.mapstruct.ap.internal.processor.DefaultModelElementProcessorContext.<init>(DefaultModelElementProcessorContext.java:50)
at org.mapstruct.ap.MappingProcessor.processMapperElements(MappingProcessor.java:218)
at org.mapstruct.ap.MappingProcessor.process(MappingProcessor.java:156)
at jdk.internal.reflect.GeneratedMethodAccessor207.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:564)
at org.jetbrains.jps.javac.APIWrappers$1.invoke(APIWrappers.java:248)
at lombok.launch.AnnotationProcessorHider$AnnotationProcessor.process(Unknown Source)
at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:1025)
at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:940)
at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1269)
at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1383)
at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1261)
at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:935)
at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.lambda$doCall$0(JavacTaskImpl.java:104)
at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.handleExceptions(JavacTaskImpl.java:147)
at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.doCall(JavacTaskImpl.java:100)
at jdk.compiler/com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:94)
at org.jetbrains.jps.javac.JavacMain.compile(JavacMain.java:231)
at org.jetbrains.jps.incremental.java.JavaBuilder.compileJava(JavaBuilder.java:501)
at org.jetbrains.jps.incremental.java.JavaBuilder.compile(JavaBuilder.java:353)
at org.jetbrains.jps.incremental.java.JavaBuilder.doBuild(JavaBuilder.java:277)
at org.jetbrains.jps.incremental.java.JavaBuilder.build(JavaBuilder.java:231)
at org.jetbrains.jps.incremental.IncProjectBuilder.runModuleLevelBuilders(IncProjectBuilder.java:1441)
at org.jetbrains.jps.incremental.IncProjectBuilder.runBuildersForChunk(IncProjectBuilder.java:1100)
at org.jetbrains.jps.incremental.IncProjectBuilder.buildTargetsChunk(IncProjectBuilder.java:1224)
at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunkIfAffected(IncProjectBuilder.java:1066)
at org.jetbrains.jps.incremental.IncProjectBuilder.access$1200(IncProjectBuilder.java:67)
at org.jetbrains.jps.incremental.IncProjectBuilder$BuildParallelizer$1.run(IncProjectBuilder.java:1006)
at com.intellij.util.concurrency.BoundedTaskExecutor.doRun(BoundedTaskExecutor.java:216)
at com.intellij.util.concurrency.BoundedTaskExecutor.access$200(BoundedTaskExecutor.java:27)
at com.intellij.util.concurrency.BoundedTaskExecutor$1.execute(BoundedTaskExecutor.java:195)
at com.intellij.util.ConcurrencyUtil.runUnderThreadName(ConcurrencyUtil.java:208)
at com.intellij.util.concurrency.BoundedTaskExecutor$1.run(BoundedTaskExecutor.java:184)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1130)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:630)
at java.base/java.lang.Thread.run(Thread.java:832)
答案 0 :(得分:2)
请更新到当前的 IDE 和 MapStruct 版本。这个问题 was fixed 很久以前。
另请参阅 this answer 以了解解决方法。
答案 1 :(得分:2)
我在 Intellij 20.3.2 中遇到 MapStruct 问题。错误 映射处理器中的内部错误:java.lang.NullPointerException:无法调用“java.net.URL.toExternalForm()”,因为“resource”为空[...]。 我做了一些研究,发现只需更改 pom.xml 中的版本就足够了。这里在文档网站我们可以看到包安装配置:https://mapstruct.org/documentation/installation/ 以下摘录仍有错误:
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
<version>**${org.mapstruct.version}**</version>
最后,在 1.4.2.Final 中放置以下版本,顺利运行应用程序。
答案 2 :(得分:1)
在您的 Intellij IDEA 中:
File | Settings | Build, Execution, Deployment | Compiler | user-local build process vm options
设置这个值:
-Djps.track.ap.dependencies=false