如何使用maven-compiler-plugin配置Lombok? [英] How to configure Lombok with maven-compiler-plugin?

查看:1287
本文介绍了如何使用maven-compiler-plugin配置Lombok?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在项目的maven中有一个根模块和子模块.我正在尝试使用龙目岛. 我已添加

I have a root module and submodule in maven in the project. I am trying to use Lombok. I have added

<dependency>
    <groupId>org.projectlombok</groupId>
    <artifactId>lombok</artifactId>
    <version>1.16.12</version>
    <scope>provided</scope>
</dependency>

根pom.xml. 在子模块中,我有一个带有Lombok批注的类. 当我尝试构建项目时,我会得到很多

to root pom.xml. In submodule I have a class with Lombok annotations. When I am trying to build the project I get a lot of

找不到符号

cannot find symbol

我试图称呼getter和setter的地方.

where I am trying to call getters and setters.

我尝试在根pom和子pom中将 lombok-maven-plugin 与相同版本(1.16.12)一起用于delombok,并将带注释的类移动到src/main/龙目岛,我已经浏览了SO中的几乎所有问题,尝试了所有变体,但没有成功.

I have tried to use lombok-maven-plugin with same version (1.16.12) in root pom and in the sub pom as well with delombok and moving my annotated class to src/main/lombok, I have looked through almost all questions in SO, try all the variants, but not succeed.

我正在使用3.6.1版本的Maven 3,Java 8,maven-compiler-plugin.

I am using Maven 3, Java 8, maven-compiler-plugin with 3.6.1 version.

我应该如何配置项目以使用lombok?也许我做错了什么.

How should I configure the project to be able to use lombok? Or maybe I am doing smth wrong.

推荐答案

我正在使用Java 8以及@Getter(onMethod = @__({@NoSerialization}))@Getter(onMethod = @__({@Translation(messageKey = "translation.key")})) onX注释.而且我在错误输出中得到了duplicate element '<any?>' in annotation @<any?>..看起来来自Lombok的人很长时间以来就一直在Java 8中遇到这样的问题要在github上发布的链接. Lombok不会在上面的注释中处理带有messageKey之类的参数的注释.它仅适用于不带参数的注释和仅具有value参数的注释(当您不写参数名称时).

I was using Java 8 and @Getter(onMethod = @__({@NoSerialization})) and @Getter(onMethod = @__({@Translation(messageKey = "translation.key")})) onX annotations. And I get duplicate element '<any?>' in annotation @<any?>. in error output. Looks like guys from Lombok have such issue with Java 8 for a long time link to issue on github. Lombok does not handle annotations with parameters like messageKey in annotation above. it works only with annotations without parameters and annotations with only value parameter (when you don't write the name of parameter).

这篇关于如何使用maven-compiler-plugin配置Lombok?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆