eclipse java 项目中 lombok.config 文件的位置

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/48111020/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 23:31:51  来源:igfitidea点击:

location of lombok.config file in java project

javaeclipselombok

提问by immu

@AllArgsConstructor(suppressConstructorProperties = true)shows following error in eclipse :

@AllArgsConstructor(suppressConstructorProperties = true)在 eclipse 中显示以下错误:

This deprecated feature is no longer supported. Remove it; you can create a lombok.config file with 'lombok.anyConstructor.suppressConstructorProperties = true'.

不再支持此已弃用的功能。去掉它; 您可以使用“lombok.anyConstructor.suppressConstructorProperties = true”创建 lombok.config 文件。

I created this file , but the errors are not going away after commenting the @AllArgsConstructor line.

我创建了这个文件,但在注释@AllArgsConstructor 行后错误并没有消失。

Can somebody please help on where to place this file exactly - I tried keeping in project root as well as src folder, but it did not work even after cleaning the project in eclipse? Do we need to do any specific action for the changes in lombok.config to reflect, like we have to restart eclipse after installing lombok.

有人可以帮忙确定这个文件的确切位置 - 我尝试保留在项目根目录和 src 文件夹中,但即使在 eclipse 中清理项目后它也不起作用?我们是否需要为 lombok.config 中的更改执行任何特定操作以反映,就像我们必须在安装 lombok 后重新启动 eclipse 一样。

I am using lombok version 1.16.18, tried 1.14.4version also, but same issue.

我正在使用 lombok 版本1.16.181.14.4也尝试过版本,但同样的问题。

回答by Daniel Taub

According to lombokYou can create lombok.configfiles in any directory and put configuration directives in it.
These apply to all source files in this directory and all child directories.
So if you want to affect all your code put the lombok.configin your root directory.

根据lombok您可以lombok.config在任何目录中创建文件并将配置指令放入其中。
这些适用于此目录和所有子目录中的所有源文件。
因此,如果您想影响所有代码,请将其lombok.config放在根目录中。

In your lombok.configfile specify

在您的lombok.config文件中指定

lombok.anyConstructor.suppressConstructorProperties=true

If true, lombok will not generate a @java.beans.ConstructorPropertiesannotation when generating constructors. This is particularly useful for GWT and Android development.

如果为 true,lombok@java.beans.ConstructorProperties在生成构造函数时不会生成 注释。这对于 GWT 和 Android 开发特别有用。

And in your class just use @AllArgsConstructorin that way :

在你的课堂上只用@AllArgsConstructor这种方式:

@AllArgsConstructor
public class Simple {
    private String text;
    private int num;
}