注释处理不适用于 lombok 和 java

4 java maven lombok

我正在开发自己的多模块项目,其中使用 lombok。当我想启动应用程序时出现问题,终端显示错误:

java: Annotation processing is not supported for module cycles. Please ensure that all modules from cycle [domain,service] are excluded from annotation processing

所以我在项目设置中关闭了注释处理 在此输入图像描述

注释处理不再出现错误modules,但出现了新错误。我使用的类lombok无法识别builder方法 java: cannot find symbol symbol: method builder(),因为 lombok 需要注释处理 - 即使 intellij 显示消息:Do you want to enable lombok annotations?当我打开 intellij 时。

有什么办法可以解决这个问题吗?

小智 5

好的,我在@xerx593用户的帮助下解决了这个问题。

它不起作用的主要原因是这部分错误: modules from cycle [domain,service]这意味着我的项目中存在模块循环。

我有三个模块:domainservice其中ui模块 service取决于domain模块, ui模块取决于,service 因此结构如下所示:domain-> service-> ui

我的pom.xml模块ui应该实现service模块依赖

我的pom.xml模块service应该实现domain模块依赖

并且pom.xmldomain模块中不应实现任何ui依赖service

但由于我的错误,我service在pom.xml中实现了依赖domain,并且出现了模块循环的问题dmoain-> service->domain

在我删除模块service中的此依赖项后domain,一切正常!