IntelliJ IDEA cannot see Lombok generated code

大城市里の小女人 提交于 2019-12-02 18:44:10
mh-dev

You need to enable the annotation preprocessor. See documentation here.

Additionally you should install the lombok plugin if not done already

Samantha Catania

I managed to solve this issue by doing the following:

  • Install the IDEA Lombok plugin
  • Enable Annotation Processing see documentation
  • Install the Latest Maven on your system and configure IntelliJ to use it (as opposed to the bundled one) see documentation

In my case the issue occurred after updating IntelliJ via Toolbox.

"Enable annotation processing" flag was switched off (despite importing the settings from previous IntelliJ version), so I switched it on. This did not resolve the issue after restart, clean, build.

However, resintalling the lombok plugin helped!

EDIT: Seems that it was the problem with compatibility of lombok plugin with IntelliJ 2018.1, plugin upgrade to 0.17 is required for IntelliJ users.

Lombok plugin changelog excerpt:

Lombok support plugin updated to v0.17: - Fixed (#465): Fix plugin compatibility with IntelliJ 2018.1

It can be seen in the build folder.

After enabled the annotation processor and installed lombok plugin, if still got "can't find symbol error" on lombok generated method, try check the gradle configuration, which is in

Preference -> Build,Execution, Deployment -> Gradle,

if you are using local gradle distribution, change to use default gradle wrapper.

I got this error when my project's gradle wrapper is 4.10.2 but my local gradle version is 5.1.1, and I solve it after I change it to use default gradle wrapper.

As mentioned in the other answer, please, install the Lombok plugin and enable the annotation processor. Press double SHIFT in the IntelliJ and type Enable annotation processing in the search box. Afterward, tick the box and restart the IDE.

In case of Lombok, IntelliJ allows you to search for usages of variable, which will also include getters and setters. Just click variable name and option/alt + f7.

This works in Intellij 2016 and Lombok plugin 0.13.16. I am not sure about older versions.

TrueIndian 31

Add below dependency in pom.xml along with other solutions mentioned in other answers.

<dependency>
    <groupId>org.projectlombok</groupId>
    <artifactId>lombok</artifactId>
    <version>1.18.2</version>
    <scope>provided</scope>
</dependency>

Try click on lombok import, and put alt+enter, then short list will appear, choose add maven dependency, then on the right down corner on the screen will appear icon that maven should be enabledd, click on enable automatically. For me it worked.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!