Rad*_*FID 3 intellij-idea maven annotation-processing mapstruct
我使用EclipseIDE 开发了一个使用的应用程序,Mapstruct我现在正在IntelliJ继续开发。
在 Eclipse 上一切正常,但由于使用了annotationProcessorPaths.
我的配置如下:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${mapstruct.version}</version>
</path>
</annotationProcessorPaths>
<source>${java.version}</source>
<target>${java.version}</target>
<compilerArgs>
<compilerArg>
-Amapstruct.defaultComponentModel=${mapstruct.defaultComponentModel}
</compilerArg>
<compilerArg>
-Aorg.hibernate.jpamodelgen.JPAMetaModelEntityProcessor
</compilerArg>
</compilerArgs>
</configuration>
Run Code Online (Sandbox Code Playgroud)
在 IntelliJ 上,当我启动 Maven 全新安装时,我得到了生成的源代码:
@Component
public class FieldMapperImpl implements FieldMapper {
@Autowired
private FieldMapperResolver fieldMapperResolver;
...
}
Run Code Online (Sandbox Code Playgroud)
但是当我运行/调试我的 Spring Boot 应用程序时,我得到的生成源是:
public class FieldMapperImpl implements FieldMapper {
private final FieldMapperResolver fieldMapperResolver = new FieldMapperResolver();
...
}
Run Code Online (Sandbox Code Playgroud)
我怎么解决这个问题 ?
我假设您直接通过 IntelliJ 运行/调试 Spring Boot 应用程序。发生这种情况的原因是 IntelliJ 没有从maven-compiler-plugin. 请参阅IDEA-143742和IDEA-150621。
您还必须单独配置 IntelliJ 注释处理器选项。您可以在 Settings -> Build, Execution, Deployment -> Compiler -> Annotation Processors 中找到
奇怪的是 IntelliJ 甚至如何调用处理器,mapstruct-processor您的 pom 中是否也有依赖项?
编辑:IntelliJ 不接受 maven-compiler-plugin 编译器参数。默认组件模型是通过注释处理器选项设置的。为了使 IntelliJ 正常工作,应该在 IntelliJ 配置中设置相同的属性或使用@Mapper(componentModel = "spring"). 文档中的更多信息
| 归档时间: |
|
| 查看次数: |
10082 次 |
| 最近记录: |