英文:
Intellij Error Duplicate Mapper Class with Auto Compile
问题
Intellij Ultimate 2020.2 Java项目,使用了Map Struct和Mapper类。构建工具是gradle。Intellij按照这里的配置(页面底部)进行了配置,但我找不到将所有构建任务配置为gradle的选项。
在启用设置 > 编译器 > 自动构建项目设置后,项目出现问题:
然后,在运行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 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:
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 {
Invalidate caches and restart does not fix the issue.
UPDATED
答案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):
It was solved IDEA-250718
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论