java lombok 使用,无法在Java 11中使用Lombok

We upgraded the Java version from 8 to 11 but I got compile errors of getter/setter methods where I implemented the POJO classes with Lombok's Getter and Setter Annotations.

Is there a way to use Lombok's @Data annotation which provides getter and setter without implementing them at Java 11?

Currently, I am facing the error:

unable to find getStoreName()

where storeName was declared as a global variable in the class with @Data Lombok annotation above the class.

解决方案

TL;DR

Upgrade Lombok as a dependency and as a IDE plugin (IntelliJ, NetBeans, Eclipse) and enable Annotation Processing in IDEs settings.

Latest version of Lombok and/or IntelliJ plugin perfectly supports Java 11.

v1.18.4 (October 30th, 2018)

...

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

...

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.

...

So please update your lombok/plugin version to the latest ones. Should work like a charm.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值