我正在尝试使用mapstruct构建一个映射器。我有一个获取String和String Varags属性的映射方法。我想在AfterMapping批注中使用varags进行一些逻辑处理。 当我运行mvn build时,我得到了与varags相关的异常(成功删除它时,build pass)。 有没有办法在mapstruct中使用varags?
这是一段代码:
@Mappings({
@Mapping(source = "code", target = "code")
})
MyResponse mapInformationToErrorData(String code, String... parameters);
构建失败,出现以下异常。
ErrorMapper.java:[20,8]映射处理器中的内部错误:org处org.mapstruct.ap.internal.util.workarounds.SpecificCompilerWorkarounds.replaceTypeElementIfNecessary(SpecificCompilerWorkarounds.java:112)处的java.lang.NullPointerException。 org.mapstruct.ap.internal.model.common.Type.getAllAccessors(Type.java:534)位于org.mapstruct.ap.internal处的mapstruct.ap.internal.util.Executables.getAllEnclosedAccessors(Executables.java:208)。 org.mapstruct.ap.internal.model.BeanMappingMethod $ Builder.applyPropertyNameBasedMapping(BeanMappingMethod.java:529)处的model.common.Type.getPropertyReadAccessors(Type.java:397)在org.mapstruct.ap.internal.model.BeanMappingMethod $在org.mapstruct.ap.internal.processor.MapperCreationProcessor.getMapper(MapperCreationProcessor.java:org.mapstruct.ap.internal.processor.MapperCreationProcessor.getMappingMethods(MapperCreationProcessor.java:373)处的Builder.build(BeanMappingMethod.java:145): 152)在org.mapst org.mapstruct.ap.internal.processor.MapperCreationProcessor.process(MapperCreationProcessor.java:80)上的ruct.ap.internal.processor.MapperCreationProcessor.process(MapperCreationProcessor.java:123)在org.mapstruct.ap.MappingProcessor.process( org.mapstruct.ap.MappingProcessor.processMapperTypeElement(MappingProcessor.java:260)位于org.mapstruct.ap.MappingProcessor.processMapperElements(MappingProcessor.java:226)位于org.mapstruct.ap.MappingProcessor.process处的MappingProcessor.java:280) (MappingProcessor.java:162),位于com.sun.tools.javac.processing.JavacProcessingEnvironment.callProcessor(JavacProcessingEnvironment.java:794),位于com.sun.tools.javac.processing.JavacProcessingEnvironment.discoverAndRunProcs(JavacProcessingEnvironment.java:705) com.sun.tools.javac.processing.JavacProcessingEnvironment.access $ 1800(JavacProcessingEnvironment.java:91)at com.sun.tools.javac.processing.JavacProcessingEnvironment $ Round.run(JavacProcessingEnvironmen t.java:1035)(com.sun.tools.javac.processing.JavacProcessingEnvironment.doProcessing(JavacProcessingEnvironment.java:1176),com.sun.tools.javac.main.JavaCompiler.processAnnotations(JavaCompiler.java:1170) com.sun.tools.javac.main.Main.compile(Main.java:523)上的.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:856)com.sun.tools.javac.api上的.sun.tools.javac.main.JavaCompiler.compile(JavaCompiler.java:856) com.sun.tools.javac.api.JavacTaskImpl.call(JavacTaskImpl.java:138)上的.javacTaskImpl.doCall(JavacTaskImpl.java:129)在org.codehaus.plexus.compiler.javac.JavaxToolsCompiler.compileInProcess(JavaxToolsCompiler.java :125),位于org.apache的org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:886),位于org.codehaus.plexus.compiler.javac.JavacCompiler.performCompile(JavacCompiler.java:171)处。位于org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginM)的maven.plugin.compiler.CompilerMojo.execute(CompilerMojo.java:129) anager.java:132),位于org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208),位于org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153),位于org org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:116)上的.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)在org.apache.maven.lifecycle.internal org.apache.maven.lifecycle.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)的.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:80)在org.apache.maven.lifecycle.internal.LifecycleStarter.execute (LifecycleStarter.java:120)在org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:355)在org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)在org.apache.maven.cli。 org.apache.maven.cli.MavenCli.doMain(MavenCli.java:216)上的MavenCli.execute(MavenCli.java:584)在org.apache.maven.cli.MavenCli.main(MavenCli.java:160)在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)在sun.reflect位于org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)处的java.lang.reflect.Method.invoke(Method.java:498)处的.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)上的org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)在org.codehaus.plexus.classworlds处。 launcher.Launcher.main(Launcher.java:356)