47

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.

Naman
  • 27,789
  • 26
  • 218
  • 353
Tonyukuk
  • 5,745
  • 7
  • 35
  • 63
  • *got compile errors* ... please share the errors as well. – Naman Dec 20 '18 at 10:37
  • it says unable to find getStoreName() where storeName was decleared as a global variable in the class with @Data Lombok annation above the class – Tonyukuk Dec 20 '18 at 10:44
  • could you update the question with the version details of both intelliJ and the plugin in use? – Naman Dec 20 '18 at 11:05
  • Intellij version: 2018.3.2..The Lombok version is v0.10-15.02 – Tonyukuk Dec 20 '18 at 11:06
  • try upgrading the plugin to `v0.22.IDEA-EAP`. – Naman Dec 20 '18 at 11:09
  • v0.10-15.02 doesn't look like a Lombok version string to me (and if it is v0.10.0, then that predates Java 11 by about 7 years). Or is it the version of the lombok-intellij-plugin? In that case it predates Java 11 by about 3 years. – Mark Rotteveel Dec 20 '18 at 16:04
  • For IntelliJ, just check the Lombok plugin, that should fix it. Lombok support Java 11 perfectly. – Eric Tan Jan 22 '21 at 12:35

3 Answers3

47

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.

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.

...

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

Mikhail Kholodkov
  • 23,642
  • 17
  • 61
  • 78
3

For eclipse users you will have to install lombok into eclipse. Please follow the instruction from here https://projectlombok.org/setup/eclipse

Purushothaman
  • 417
  • 4
  • 6
0

As general, update lombok dependency can fix the problem. Like vsrsion 1.18.4 or latter work fine with JDK11.

jngcs
  • 11
  • 2