简体   繁体   English

如何在 IntelliJ IDEA 14 中为当前项目工作配置注释处理?

[英]How to configure annotations processing in IntelliJ IDEA 14 for current project work?

The structure of the project is:该项目的结构是:

  • Parent project父项目
    • A project (Spring) have dependency of project B in pom.xml一个项目(Spring)在 pom.xml 中有项目 B 的依赖
    • B project (Spring MVC) have dependency of project A in pom.xml B 项目(Spring MVC)在 pom.xml 中有项目 A 的依赖

After launching project B in Tomcat 7, I have an error:在Tomcat 7中启动项目B后,出现错误:

Error:java: Annotation processing is not supported for module cycles.错误:java:模块周期不支持注释处理。 Please ensure that all modules from cycle [A,B] are excluded from annotation processing请确保周期 [A,B] 中的所有模块都被排除在注释处理之外

How do I avoid this problem?我如何避免这个问题?

I use Java 8, Tomcat 7 and Intellij Idea 14.我使用 Java 8、Tomcat 7 和 Intellij Idea 14。

To solve these kind of problems need to use Analyze Module dependencies in InteliJ-idea.为了解决这类问题,需要使用 InteliJ-idea 中的分析模块依赖关系。

File Menu > Analyze > Module Dependencies文件菜单 > 分析 > 模块依赖

This shows the list of all projects which have cyclic dependencies and should be resolved first.这显示了所有具有循环依赖项并应首先解决的项目的列表。

This feature helps you to find the problem.此功能可帮助您找到问题。

EDIT – For the latest version, it is Analyze -> Analyze Module Dependencies..编辑- 对于最新版本,它是分析 -> 分析模块依赖关系..

In addition to Mikhails answer, here is how to fix it :除了 Mikhails 的回答,这里是如何修复它

When you saw which modules have cyclic dependencies, right-click your project and当您看到哪些模块具有循环依赖项时,右键单击您的项目并

Open Module Settings -> Expand the according module-group and select the module -> Dependencies -> select and remove it Open Module Settings ->展开相应的模块组并选择模块-> Dependencies ->选择并删除它

Not sure if it was the actual solution, but I had a similar issue on migrating our multi-module Maven Project to Idea 14. 不确定它是否是实际的解决方案,但我在将多模块Maven项目迁移到Idea 14时遇到了类似的问题。

Parent

  • junit 1.2.16 junit 1.2.16

Module A 模块A.

  • junit 1.2.17 junit 1.2.17

Module B 模块B.

  • junit 1.2.16 junit 1.2.16
  • Module A 模块A.

It failed to execute when I was trying to run an unit test from Module A. Totally removing junit from the modules resolved it for me. 当我尝试从模块A运行单元测试时,它无法执行。完全从模块中删除junit为我解决了它。 No idea why, but maybe you're having a similar set-up? 不知道为什么,但也许你有类似的设置?

If the circular dependency is wrong then open Module Settings and remove it from the module(s) that should not have it.如果循环依赖错误,则打开模块设置并将其从不应该具有它的模块中删除。

If the dependency is correct then uncheck the Enable annotation processing box in File | Settings | Build, Execution, Deployment | Compiler | Annotation Processors如果依赖项正确,则取消选中File | Settings | Build, Execution, Deployment | Compiler | Annotation Processors中的Enable annotation processing框。 File | Settings | Build, Execution, Deployment | Compiler | Annotation Processors

在此处输入图片说明

Going into Settings->Build->Compiler->Annotation Processors and disabling it solved it.进入 Settings->Build->Compiler->Annotation Processors 并禁用它解决了它。

Allowing Test-A to depend on B, even though B depends on A允许测试-A 依赖于 B,即使 B 依赖于 A

I'm using IntelliJ2019.1我正在使用 IntelliJ2019.1

But it's sad it doesn't seem to consider the maven test scope但是很遗憾它似乎没有考虑 maven 测试范围

An alternative in order to solve this problem that worked for me (the above answers didn't).为了解决这个对我有用的问题的替代方法(上面的答案没有)。

Go to the pom.xml from the package / project that you have.从您拥有的包/项目转到pom.xml Delete the tag that is causing the issue.删除导致问题的标签。 You can find the dependecy with the issue in the console.您可以在控制台中找到问题的相关性。

Hope it helps.希望能帮助到你。 :) :)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM