Lombok with IDEA 13: Cannot find symbol
Asked Answered
P

11

21

I have tried using Lombok on Intellij IDEA 13 Ultimate. However. I get the famous error "cannot find symbol" for all the methods that should have been available when I am using specific annotations for example the once I use as annotations are @Builder, @AllArgsConstructor and @Data.

I have already set my compiler to enable annotation processing and I have looked deeply into it, but with no solution of how to solve it.

Any advice or tips would be nice.

Pentomic answered 17/4, 2015 at 7:21 Comment(4)
Have you installed the lombok plugin for IDEA? plugins.jetbrains.com/plugin/6317Zweig
jupp. the latest onePentomic
Are you using Maven? Have you made sure that the jar is on the classpath?Zweig
Have you solved it already? It's happening to me too.Merely
V
11

Kind of old question here, but I came across the same problem today. I had to do two things to make it work:

  1. Set annotation processing on: Settings -> Compiler -> Annotation Processors
  2. Change from ajc to javac for the project: Compiler -> Java Compiler

you of course also need the Lombok plugin.

Voltmeter answered 23/3, 2016 at 20:24 Comment(4)
If i do this, Lombok works, but aspectJ doesn't. Am I missing something?Hardeman
did that, but i also had to (obviously) install lombok plugin.Chanda
not working for me , having same error :java: cannot find symbol symbol: class __Haworth
@prashantkute are you able to fix your issue. i am also facing the sameClosing
M
6

In my case non of methods works. But I found solution for my case. I needed to add to my Gradle dependencies list of

dependencies {
    compileOnly 'org.projectlombok:lombok:1.18.22'
}

one more line

dependencies {
    compileOnly 'org.projectlombok:lombok:1.18.22'
    annotationProcessor 'org.projectlombok:lombok:1.18.22'
}

With such combination you even don't need enabling Annotation Processors from @Vegard answer.

Miterwort answered 29/1, 2022 at 18:59 Comment(0)
L
3

In my case apart from enabling Annotation Processing and installing Lombok Plugin I had to rebuild project by Build -> Rebuild Project

Lafond answered 17/12, 2020 at 15:14 Comment(0)
D
3

I have the same problem. Using maven, after I add at to my pom.xml annotationProcessor nothing changed. Also I'm installed Lombok plugin at Intelij IDEA.

<annotationProcessorPaths>
    <path>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <version>1.18.20</version>
    </path>
</annotationProcessorPaths>
Danny answered 24/8, 2022 at 12:38 Comment(1)
Gracias, I won it's troubble with replaced my project at Default in Settings -> Build -> Annotation Processors and it works. Thanks!Danny
S
1

I was having a similar issue, but resolved it by upgrading to IDEA 15.0.2 and Lombok plugin 0.9.6.14. I had to restart IDEA several times before all of the getters/setters generated by Lombok were resolved.

I also found this related answer, but it didn't seem to help my problem. It may help you if upgrading does not.

Skull answered 29/12, 2015 at 22:40 Comment(0)
D
1

Tried with the @Mike's solution above, and it works. For your information, even though I enabled the Annotation Processors , but it seems like not working. After I added the annotationProcessor 'org.projectlombok:lombok:1.18.22' it was built successfully.

Diaconate answered 31/7, 2022 at 2:45 Comment(0)
S
0

If you use intellij Idea go to setting and add Lombok plugin to your intellij idea

enter image description here

Sultana answered 21/7, 2022 at 17:46 Comment(0)
L
0

I solved this in my Gradle project by including the Lombok plugin. No dependencies or annotationProcessor needed (nor did those work for me).

For example in your build.gradle.kts:

plugins {
    id("io.freefair.lombok") version "6.5.1"
}

https://plugins.gradle.org/plugin/io.freefair.lombok

Locular answered 8/10, 2022 at 19:31 Comment(0)
N
0

The aforementioned solutions work perfectly, although there's another instance where Lombok annotation processing can fail:

In Gradle or Maven you can pass an argument/flag to prevent annotation processing:

-proc:none

Hope this helps someone.

Reference: https://github.com/projectlombok/lombok/issues/1449

Nada answered 26/9, 2023 at 14:38 Comment(0)
I
0

If you use @UtilityClass, the reason can be: Due to a peculiar way javac processes static imports, trying to do a non-star static import of any of the members of a @UtilityClass won't work. Either use a star static import: import static TypeMarkedWithUtilityClass.*; or don't statically import any of the members.

Insouciant answered 17/5, 2024 at 14:42 Comment(0)
N
0

Same problem here, hundreds of Lombok errors in @Builder tags and getting this compile error cannot find symbol.

The solution for me was to check all the errors and see that one of them was different import requires canonical name for caused by the @FieldNameConstants annotation conflicting with other classes.

Conclusion: Lombok sucks!

Nadler answered 13/6, 2024 at 8:58 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.