IntelliJ错误:重复的Mapper类与自动编译

huangapple go评论135阅读模式
英文:

Intellij Error Duplicate Mapper Class with Auto Compile

问题

Intellij Ultimate 2020.2 Java项目,使用了Map Struct和Mapper类。构建工具是gradle。Intellij按照这里的配置(页面底部)进行了配置,但我找不到将所有构建任务配置为gradle的选项。

在启用设置 > 编译器 > 自动构建项目设置后,项目出现问题:

IntelliJ错误:重复的Mapper类与自动编译

然后,在运行gradle构建任务时,我收到了重复类错误。这是IDE抱怨的重复类示例:

C:\Users\User\IdeaProjects\Dep\build\generated\sources\annotationProcessor\java\main\test\pot\service\mapper\TaskCodeMapperImpl.java:16: 错误: 重复类: test.pot.service.mapper.TaskCodeMapperImpl
public class TaskCodeMapperImpl implements TaskCodeMapper {

IntelliJ错误:重复的Mapper类与自动编译

清除缓存并重新启动无法解决此问题。

更新

IntelliJ错误:重复的Mapper类与自动编译

英文:

Intellij Ultimate 2020.2 Java & Jhipster project which uses Map Struct and Mapper classes. The build tool is gradle. Intellij configuered as per here (bottom of page), however I could not find the option to configure all build tasks to gradle.

Project was fine until I enabled Settings > Compiler > Build Project Automatically setting:

IntelliJ错误:重复的Mapper类与自动编译

Then I get duplicate class errors when running the gradle build task. This is the duplicate class the IDE complains about. For example:

C:\Users\User\IdeaProjects\Dep\build\generated\sources\annotationProcessor\java\main\test\pot\service\mapper\TaskCodeMapperImpl.java:16: error: duplicate class: test.pot.service.mapper.TaskCodeMapperImpl
public class TaskCodeMapperImpl implements TaskCodeMapper {

IntelliJ错误:重复的Mapper类与自动编译

Invalidate caches and restart does not fix the issue.

UPDATED

IntelliJ错误:重复的Mapper类与自动编译

答案1

得分: 2

有一个bug,当IDE启用了Build Project Automatically选项时,即使设置了Build and Run Using: Gradle,IDE也会使用自己的构建器进行自动构建:IDEA-212052

作为一种解决方法,请禁用Build Project Automatically选项。

英文:

There is a bug when IDE will uses it's own builder for auto-make (even though Build and Run Using: Gradle is set) when Build Project Automatically option is enabled: IDEA-212052.

As a workaround please disable Build Project Automatically option.

答案2

得分: 0

但如果您仍然想要启用自动构建项目选项,
还有另一种解决方案,即在**用户本地构建过程 VM 选项(覆盖共享选项)**中添加 -Djps.track.ap.dependencies=false

这个问题已经被解决了IDEA-250718

英文:

But still if You wanna let Build Project Automatically option,

there is another solution -Djps.track.ap.dependencies=false in User-loca build process VM options (overrides Shared options):

IntelliJ错误:重复的Mapper类与自动编译

It was solved IDEA-250718

huangapple
  • 本文由 发表于 2020年8月6日 15:48:10
  • 转载请务必保留本文链接:https://go.coder-hub.com/63279053.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定