解决使用mapstruct过程中的一次编译报错问题_Internal error in the mapping processor
说明
- mapstruct版本:1.2.0.Final
- 开发工具:IntelliJ IDEA 2021.3.1 (Ultimate Edition)
报错现象
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 org.jetbrains.jps.javac.APIWrappers$ProcessorWrapper.process(APIWrappers.java:157) 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:313) 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:238) at org.jetbrains.jps.incremental.java.JavaBuilder.lambda$compileJava$2(JavaBuilder.java:518) at org.jetbrains.jps.incremental.java.JavaBuilder.invokeJavac(JavaBuilder.java:564) at org.jetbrains.jps.incremental.java.JavaBuilder.compileJava(JavaBuilder.java:516) at org.jetbrains.jps.incremental.java.JavaBuilder.compile(JavaBuilder.java:359) at org.jetbrains.jps.incremental.java.JavaBuilder.doBuild(JavaBuilder.java:284) at org.jetbrains.jps.incremental.java.JavaBuilder.build(JavaBuilder.java:238) at org.jetbrains.jps.incremental.IncProjectBuilder.runModuleLevelBuilders(IncProjectBuilder.java:1529) at org.jetbrains.jps.incremental.IncProjectBuilder.runBuildersForChunk(IncProjectBuilder.java:1163) at org.jetbrains.jps.incremental.IncProjectBuilder.buildTargetsChunk(IncProjectBuilder.java:1310) at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunkIfAffected(IncProjectBuilder.java:1128) at org.jetbrains.jps.incremental.IncProjectBuilder.buildChunks(IncProjectBuilder.java:877) at org.jetbrains.jps.incremental.IncProjectBuilder.runBuild(IncProjectBuilder.java:459) at org.jetbrains.jps.incremental.IncProjectBuilder.build(IncProjectBuilder.java:197) at org.jetbrains.jps.cmdline.BuildRunner.runBuild(BuildRunner.java:131) at org.jetbrains.jps.cmdline.BuildSession.runBuild(BuildSession.java:334) at org.jetbrains.jps.cmdline.BuildSession.run(BuildSession.java:162) at org.jetbrains.jps.cmdline.BuildMain$MyMessageHandler.lambda$channelRead0$0(BuildMain.java:218) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)
解决方案
方案一
修改IDEA设置:
Setting -->Build,Execution,Deployment -->Compiler -->User-local build process VM options (overrides Shared options) 下添加配置:
-Djps.track.ap.dependencies=false
方案二
修改mapstruct版本:mapstruct框架引入版本升至1.4.1.Final或更高版本
原因分析
null