编程语言
首页 > 编程语言> > 无法将Lombok与Java 11一起使用

无法将Lombok与Java 11一起使用

作者:互联网

我们将Java版本从8升级到11但是我得到了getter / setter方法的编译错误,其中我使用Lombok的Getter和Setter Annotations实现了POJO类.

有没有办法使用Lombok的@Data注释,它提供getter和setter而不在Java 11中实现它们?

目前,我面临的错误是:

unable to find getStoreName()

其中storeName被声明为类中的全局变量,其中@Data Lombok注释位于类之上.

解决方法:

TL; DR

将Lombok升级为dependency和IDE插件(IntelliJ,NetBeans,Eclipse)并在IDE设置中启用注释处理.

最新版本的Lombok和/或IntelliJ插件完美支持Java 11.

https://projectlombok.org/changelog

v1.18.4 (October 30th, 2018)

  • PLATFORM: Many improvements for lombok’s JDK10/11 support.

https://github.com/mplushnikov/lombok-intellij-plugin

Provides support for lombok annotations to write great Java code with
IntelliJ IDEA.

Last version (0.23) released on 17.12.2018

  • Tested and supports IntelliJ versions: 2016.2, 2016.3, 2017.X, 2018.X

Lombok project dependency

Make sure you have Lombok dependency added
to your project. This plugin does not automatically add it for you.

Please Note: Using newest version of the Lombok dependency is
recommended, but does not guarantee that all the features introduced
will be available. See Lombok changelog for more details.

所以请将您的lombok /插件版本更新为最新版本.应该像魅力一样工作.

标签:lombok,java-11,java,intellij-lombok-plugin
来源: https://codeday.me/bug/20191006/1859010.html