Java 8 的 Lombok 问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27824973/
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-11-02 12:27:13  来源:igfitidea点击:

Lombok issues with Java 8

javaspringintellij-ideajava-8lombok

提问by paul

I just upgrade to Intellij idea 14 and Java 8 and I had on mind to upgrade my project to Java version 8 as well, to start using some new features. But After configure the Intellij properly to use Java 8 I have still the issue with Lombok. Looks like there′s a conflict between Java 8 and lombok because now my @Getterand @Setterannotations do not work anymore.

我刚刚升级到 Intellij idea 14 和 Java 8,我还想将我的项目也升级到 Java 版本 8,以开始使用一些新功能。但是在正确配置 Intellij 以使用 Java 8 后,我仍然遇到 Lombok 的问题。看起来 Java 8 和 lombok 之间存在冲突,因为现在我的@Getter@Setter注释不再起作用了。

The version of lombok is 1.10.8. Any suggestions?

lombok 的版本是 1.10.8。有什么建议?

回答by Magnilex

Short answer:

简答:

Lombok supports Java 8, and has done so since version 1.12.2.

Lombok 支持 Java 8,并且从 1.12.2 版开始就支持了。



Long answer

长答案

Lombok supports Java 8, and has done so since version 1.12.2 (October 10th, 2013) according to the changelog:

根据更新日志,Lombok 支持 Java 8,并且从 1.12.2 版(2013 年 10 月 10 日)开始支持:

PLATFORM:Initial JDK8 support, without affecting existing support for JDK6 and 7. Issue #451. While lombok will now work on JDK8 / javac8, and netbeans 7.4 and up, lombok does not (yet) support new language features introduced with java8, such as lambda expressions. Support for these features will be added in a future version.

平台:最初的 JDK8 支持,不影响对 JDK6 和 7 的现有支持。问题 #451。虽然 lombok 现在可以在 JDK8 / javac8 和 netbeans 7.4 及更高版本上运行,但 lombok 尚不支持 java8 引入的新语言功能,例如 lambda 表达式。将在未来版本中添加对这些功能的支持。

Since then further Java 8 support has been implemented:

从那时起,实现了进一步的 Java 8 支持:

  • v1.12.6 (March 6th, 2014)

    PLATFORM:Initial JDK8 support for eclipse's alpha support in kepler. Issue #597

  • v1.14.0 "Branching Cobra" (May 27th, 2014)

    BUGFIX:Usage of @SneakyThrows with a javac from JDK8 with -target 1.8 would result in a post compiler error. Issue #655
    BUGFIX:Major work on improving support for JDK8, both for javac and eclipse.

  • v1.14.6 (September 2nd, 2014)

    BUGFIX:Usage of val would break starting with JDK8 release 1.8.0_20. Issue #731

  • v1.12.6(2014 年 3 月 6 日)

    平台:最初的 JDK8 支持 eclipse 在 kepler 中的 alpha 支持。问题 #597

  • v1.14.0 “分支眼镜蛇”(2014 年 5 月 27 日)

    BUGFIX:将 @SneakyThrows 与 JDK8 中的 javac 与 -target 1.8 一起使用会导致编译后错误。问题 #655
    BUGFIX:改进对 JDK8 支持的主要工作,包括 javac 和 eclipse。

  • v1.14.6(2014 年 9 月 2 日)

    BUGFIX:从 JDK8 版本 1.8.0_20 开始,val 的使用会中断。问题 #731

In other words, the newest version of Lombok should be able to work with Java 8 fairly well, and since version 1.12.2, Java 8 code without the new language features should work.

换句话说,最新版本的 Lombok 应该能够很好地与 Java 8 一起工作,并且从 1.12.2 版本开始,没有新语言特性的 Java 8 代码应该可以工作。



EDIT: As Roelpointed out, there is currently (8th january 2015) an open bugspecifying that one specific Lombok feature (val) stopped working for 1.14.8.

编辑:正如Roel 所指出的,目前(2015 年 1 月 8 日)有一个公开的错误,指出一个特定的 Lombok 功能 ( val) 在 1.14.8 中停止工作。

This bug was closed 16th November 2015.

此错误已于 2015 年 11 月 16 日关闭。