【开发心得】从 IntelliJ 2020.3EAP #2215运行 MapStruct 时的 NPE
问题:
ava: Internal error in the mapping processor: java.lang.NullPointerException 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:54) at org.mapstruct.ap.MappingProcessor.processMapperElements(MappingProcessor.java:264) at org.mapstruct.ap.MappingProcessor.process(MappingProcessor.java:166) at org.jetbrains.jps.javac.APIWrappers$ProcessorWrapper.process(APIWrappers.java:59) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.base/java.lang.reflect.Method.invoke(Method.java:566) at org.jetbrains.jps.javac.APIWrappers$1.invoke(APIWrappers.java:162) at com.sun.proxy.$Proxy18.process(Unknown Source) at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:980) at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:896) at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment$Round.run(JavacProcessingEnvironment.java:1222) at jdk.compiler/com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1334) at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1258) at jdk.compiler/com.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:936) 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.Ja
原因: mapStruct版本低了,估计遇到这个问题的朋友,都是引入了mybatisPlus,用的mapperStruct版本为1.2,如果无法升级版本,可以考虑按照如下解决方案处理。
解决方案:
编辑:要修复 IDEA 2020.3+ 中的错误,请升级到 1.4.1.Final 或更高版本。
如果您坚持使用旧版本,作为一种解决方法,您可以-Djps.track.ap.dependencies=false添加File | Settings | Build, Execution, Deployment | Compiler | User-local build process VM options (overrides Shared options)