I'm trying to use Lombok in my project that I'm developing using IntelliJ IDEA 11.
I've installed 3rd-party plugin for IDEA and it seems working fine because IDEA sees all autogenerated methods/fields.
So I have a class that uses Slf4j. I annotated it like this
import lombok.extern.slf4j.Slf4j;
#Slf4j
public class TestClass
{
public TestClass()
{
log.info("Hello!");
}
}
But when I build my project compiler spits: cannot find symbol variable log.
Could you please tell me what I'm missing here?
Update: It turned out it's RequestFactory annotation process that fails.
input files: {com.zasutki.courierApp.server.TestServlet, com.mine.courierApp.server.model.DatastoreObject}
annotations: [javax.inject.Singleton, javax.inject.Inject, lombok.Getter, lombok.Setter, com.googlecode.objectify.annotation.Id, com.googlecode.objectify.annotation.OnSave]
Processor com.google.web.bindery.requestfactory.apt.RfValidator matches [lombok.Getter, com.googlecode.objectify.annotation.Id, javax.inject.Inject, lombok.Setter, com.googlecode.objectify.annotation.OnSave, javax.inject.Singleton] and returns false.
cannot find symbol variable log
Any ideas on workarounds?
Update2: Perhaps it's not something readers want to hear but I ended up switching to Scala.
I have fixed it in IDEA 12 by setting check box Enable annotation processing in:
Settings -> Compiler -> Annotation Processors
For IDEA 2016.2:
Preferences... > Build, Execution, Deployment > Compiler > Annotation Processors
After enabling, run Build -> Rebuild Project to have annotations recognized and eliminate errors.
For IDEA 2019.2.1, depending on how the project is configured, installing the Project Lombok plugin may not be sufficient. Here is another way to use Project Lombok with IntelliJ IDEA:
Visit https://projectlombok.org/download
Download the JAR file into the project lib directory (e.g., $HOME/dev/java/project/libs).
Start the IDE.
Click File 🠖 Settings.
Expand Build, Execution, Deployment 🠖 Compiler 🠖 Annotation Processors.
Ensure Enable annotation processing is checked.
Ensure Store generates sources relative to is selected based on the project's module settings (if Module output directory doesn't work, come back and try the other setting).
Click Apply.
Click Plugins.
Click Marketplace.
Set search field to: lombok
Install Lombok.
Click OK.
Restart the IDE if prompted.
Click File 🠖 Project Structure.
Select Libraries.
Click the + symbol to add a new project library (or press Alt+Insert).
Select Java.
Set the path to: $HOME/dev/java/project/libs/lombok.jar
Click OK.
Select the modules to apply.
Click OK.
Optionally, rename lombok to Project Lombok 1.18.8.
Click OK.
The project can now import from the lombok package and use Project Lombok annotations (e.g., lombok.Setter and lombok.Getter).
Picture representation of resolving this issue.
First enable annotation processors and try. This may or may not work.
Post that, you can install the lombok plugin from intellij, (After installation Intellij will restart to enable the plugin, so make sure you save your work.(Intellij does save all the changes before restart, just to be on the safe side.)) screenshot below:
Enabling annotation processing will make it work
But if you are on a Mac, make sure you enable annotation processing(tick the checkbox) from both the places available.
1.) Intellij Idea -> Preferences -> Compiler -> Annotation Processors
2.) File -> Other Settings -> Default Settings -> Compiler -> Annotation Processors
Make sure it's added correctly to your project.
example for Gradle:
dependencies {
compileOnly 'org.projectlombok:lombok:1.18.8'
annotationProcessor 'org.projectlombok:lombok:1.18.8'
...
}
Install Lombok plugin for your IDE
Check "Enable annotation processing" checkbox in IDE (IntellijIdea), have no idea if there is anything like this for other IDEs like Eclipse.
in the latest Gradle version you should use annotationProcessor:
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok:1.18.8'
I'm using IntelliJ IDEA 2020.3 (Community Edition)
Here, besides install the Lombok plugin and enable annotations (explained by other answers). I also needed to set the flag -Djps.track.ap.dependencies=false to the Build Process Option¹.
I didn't need to use the -javaagent approach, neither setup the classpath.
¹. Go to: File | Settings | Build, Execution, Deployment | Compiler | "Shared build process VM options" field
References:
https://github.com/rzwitserloot/lombok/issues/2592#issuecomment-705449860
https://youtrack.jetbrains.com/issue/IDEA-250718#focus=Comments-27-4418347.0-0
Just for reference using IntelliJ 2018.3, I solved this issue (using #Data annotation to insert getter/setter) following the three steps:
File -> Settings -> Build, Execution, Deployment -> Annotation Processors -> Enable Annotation Processing;
Do remember to Apply the change.
Install plugin lombok in the same setting dialog;
It seems good enough for now, it requires to restart IntelliJ and then rebuild your project.
Best wishes :)
If you have checked both these steps as follows
Enable annotations : this is a check done in IntelliJ
preferences.
Importing lombok into IntelliJ classPath
(Preferences -> Plugins)
and still getting errors then please check the compiler - if it is JAVAC or ECLIPSE.
You can check the compiler in Preferences -> Build,Execution,Deployment -> Compiler -> Java Compiler.
Change the Use compiler to Javac (if it is Eclipse). This is what worked for me.
Including the following in the pom.xml is what worked for me:
<build>
<defaultGoal>spring-boot:run</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<annotationProcessorPaths>
...
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</build>
As noted here, quote: "You should activate external compiler option and enable annotation processors or disable external compiler and disable all of annotation compilers to work with lombok". This fixed my problem. Note that I added the Scala plugin prior to receiving this error, so I suspect the plugin changed some of the above settings.
there is a plugin for intellij. see here: https://projectlombok.org/download.html
Do you have lombok as dependency of your project? lombok.jar must be on the classpath during compiling of the project, which is using any of lombok-annotations.
For those of you who are still having trouble:
In addition to the above steps of enabling annotation processors and installing the IntelliJ Lombok plugin, I also had to Build -> Rebuild Project.
1、install lombok plugin for IDEA
Intellij Idea -> Preferences -> Plugins -> type in lombok -> Search in Repositories -> install -> restart IDEA
2、 config lombok plugin
Enabling annotation processing will make it work
But if you are on a Mac, make sure you enable annotation processing in the following two places:
Intellij Idea -> Preferences -> Build, Execution, Deployment -> Compiler -> Annotation Processors, check the checkbox of "Enable annotation processing".
File -> Other Settings -> Default Settings -> Build, Execution, Deployment -> Compiler -> Annotation Processors, check the checkbox of "Enable annotation processing".
I was on Mac
This is my IntelliJ IDEA and Mac Version - IntelliJ IDEA 2017.1.5 Build #IU-171.4694.70 --- Mac OS X 10.12
In addition to enabling annotation processing (tick the checkbox) at these 2 places.
1.) Intellij IDEA -> Preferences -> Compiler -> Annotation Processors
.
2.) File -> Other Settings -> Default Settings -> Compiler -> Annotation Processors
I had to install Lombok plugin too to make it work.
3.) Intellij IDEA -> Preferences -> Plugins ->Browse Repositories-> Search for "Lombok"-> install plugin -> Apply and restart IDEA
It didn#t work for me with any of the above solutions. I added <scope>provided</scope> to the dependency in pom.xml and it worked.
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.20</version>
<scope>provided</scope>
</dependency>
If you already installed it, then for refresh just deselect and select Enable annotation in Intellij Settings.
I have faced this problem after updating the IDEA to 2018.3. I had to update all the existing plugin
After trying all the suggestions here, I have also find another kind of solution. It seems that sometimes IDEA can not obtain processors from project classpath.
So, on the Annotation Processors settings tab, you have to manually specify Processor path.
Apart from mentioned in all answers I have to add the below code in pom.xml configuration to makes mvn clean install work. Before adding this code I was getting cannot found symbol for getters and setters.
<annotationProcessorPath>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.8</version>
</annotationProcessorPath>
For me what worked:
I uninstalled the installed the Lombok plugin freshly
I ticked "Enable Annotation Plugin"
I selected "Obtain processor from the project classpath" in the same page
For IntelliJ IDEA 2020.1.1 enabling Kotlin plugin fixed this issue.
If you did everything mentioned in this question and It's still failing, don't forget to remove /target folder under your projects. And If it's still failing, restart your IDE.
And If it's still failing restart your computer.
The Jetbrains IntelliJ IDEA editor is compatible with lombok without a plugin as of version 2020.3.
I was using 2020.2 version, i updated to 2020.3 it worked just like that.
I don't think I read my final step in the answers yet. (Mac + IntelliJ Ultimate 2020.1)
Its just a silly cause in my case, but those are the ones that can take up most time because the error doesnt directly refer to it.
The same lombok error appeared to me after deleting and recloning the project.
After doing the steps mentioned earlier in this thread I still had the error, I then discovered my SKD was defaulted to version 11. I changed this back to 1.8 and everything worked again.
File --> Project Settings --> Project
I changed the Project SDK and the Project language level to 1.8
PS the location for the default settings on the mac is different in this IntelliJ version than mentioned before :
File --> New Project Settings --> Preferences for new Projects --> Build, Execution, Deployment --> Compiler --> Annotation Processors --> 'check' Enable annotation processing
Hope this helps anybody
If none of the above did'nt work , then try to change File->Project Structure->Project->Project Language Level > 8 Lambda,type annotations (Not SDK Default 8)
This worked for me .
I tried enabling lambok, restarted intellij, etc but below worked for me.
Intellij Preferences ->Compiler -> Shared Build process VM Options and set it to
-Djps.track.ap.dependencies=false
than run
mvn clean install
It may happen that even if you have it configured properly and it is visible among the libraries and in Gradle dependencies list, IntelliJ still does not have it in class path. Or it is there, but configured with different scope (ex: test instead of compile.)
First, make sure you have plugin installed and annotation processing enabled, as stated in other answers.
If you still have annotation not recognized, place cursor on it, hit ALT+ENTER (or OPTION+ENTER) and see if you have a menu option Add library: Gradle: org.projectlombok:lombok:VERSION to class path. If you can see it, choose this one and it may solve your problem.
You may check the library and it's scope in:
Project settings / Modules / Dependencies tab (search for lombok in there)
I had a similar issue when building with JDK8, set the project back to JDK7 and it worked fine. Could be an older version of Lombok that won't compile under JDK8.
If you tried all solutions presented here and still can't compile sources, also look here: Static import of builder class breaks bytecode generation in Maven - look at your sources if it has such static imports. This affects maven plugin, so compilation will fail on other build systems outside IntelliJ IDEA.
Related
I use IntelliJ IDEA as my development environment, and Maven for dependency management. I frequently build my project structure (directories, poms, etc) outside of IDEA and then import the project into IDEA using Import project from external model. This works great, except that in my poms I specify that the maven-compiler-plugin should use JDK 1.6, and when I import, IDEA informs me that the Language Level Changed and that Language level changes will take effect on project reload, and then prompts to reload the project. This is annoying because I always use the same JDK version.
How do I change the default JDK that IntelliJ IDEA uses, so that I don't have to reload my project every time I import a new project?
This setting is changed in the "Structure for New Projects" dialog. Navigate to "File" -> "New Projects Setup" -> "Structure..."
Next, modify the "Project SDK" and "Project Language Level" as appropriate.
Previous versions of IntelliJ IDEA had this setting in "File" -> "Other Settings" -> "Default Project Structure...".
IntelliJ IDEA 12 had this setting in "Template Project Structure..." instead of "Default Project Structure..."
Download and unpack a JDK archive file (.tar.gz) and add it as a SDK in the 'Project Structure' dialog box ( Ctrl+Alt+Shift+S )
click on the gif to enlarge
Also make sure to set an appropriate 'Project language level'. I forgot to do that when creating the GIF.
Project Structure > Project > Project language level
For Java 8 set it to 8, for Java 9 set it to 9, and so on.
I am using IntelliJ IDEA 14.0.3, and I also have same question. Choose menu File \ Other Settings \ Default Project Structure...
Choose Project tab, section Project language level, choose level from dropdown list, this setting is default for all new project.
I have found out that in recent versions of IntelliJ IDEA requires Java 1.8 but is not configured by default.
We can change the path or configure from Project Settings > Project > Project SDK
here we can edit or add the JDK´s path.
(in my case the path is located in C:\Program Files\Java\jdk1.8.0_102)
Change JDK version to 1.8
Language level File -> project Structure -> Modules -> Sources -> Language level -> 8-Lambdas, type annotations etc.
Project SDk File -> project Structure -> Project 1.8
Java compiler File -> Settings -> Build, Executions, Deployment -> Compiler -> Java compiler
One other place worth checking: Look in the pom.xml for your project, if you are using Maven compiler plugin, at the source/target config and make sure it is the desired version of Java. I found that I had 1.7 in the following; I changed it to 1.8 and then everything compiled correctly in IntelliJ.
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
</build>
The above responses were very useful, but after all settings, the project was running with the wrong version. Finally, I noticed that it can be also configured in the Dependencies window.
Idea 2018.1.3 File -> Project Structure -> Modules -> Sources and Dependencies.
To change the JDK version of the Intellij-IDE himself:
Start the IDE -> Help -> Find Action
than type:
Switch Boot JDK
or (depend on your version)
Switch IDE boot JDK
For latest version intellij, to set default jdk/sdk for new projects go to
Configure->Structure for New Projects -> Project Settings -> Project SDK
I am using IntelliJ 2020.3.1 and the File > Other Settings... menu option has disappeared. I went to Settings in the usual way and searched for "jdk". Under Build, Execution, Deployment > Build Tools > Maven > Importing I found the the setting that will solve my specific issue:
JDK for importer.
On my linux machine I use a script like this:
export IDEA_JDK=/opt/jdk14
/idea-IC/bin/idea.sh
I'm trying to use Lombok in my project that I'm developing using IntelliJ IDEA 11.
I've installed 3rd-party plugin for IDEA and it seems working fine because IDEA sees all autogenerated methods/fields.
So I have a class that uses Slf4j. I annotated it like this
import lombok.extern.slf4j.Slf4j;
#Slf4j
public class TestClass
{
public TestClass()
{
log.info("Hello!");
}
}
But when I build my project compiler spits: cannot find symbol variable log.
Could you please tell me what I'm missing here?
Update: It turned out it's RequestFactory annotation process that fails.
input files: {com.zasutki.courierApp.server.TestServlet, com.mine.courierApp.server.model.DatastoreObject}
annotations: [javax.inject.Singleton, javax.inject.Inject, lombok.Getter, lombok.Setter, com.googlecode.objectify.annotation.Id, com.googlecode.objectify.annotation.OnSave]
Processor com.google.web.bindery.requestfactory.apt.RfValidator matches [lombok.Getter, com.googlecode.objectify.annotation.Id, javax.inject.Inject, lombok.Setter, com.googlecode.objectify.annotation.OnSave, javax.inject.Singleton] and returns false.
cannot find symbol variable log
Any ideas on workarounds?
Update2: Perhaps it's not something readers want to hear but I ended up switching to Scala.
I have fixed it in IDEA 12 by setting check box Enable annotation processing in:
Settings -> Compiler -> Annotation Processors
For IDEA 2016.2:
Preferences... > Build, Execution, Deployment > Compiler > Annotation Processors
After enabling, run Build -> Rebuild Project to have annotations recognized and eliminate errors.
For IDEA 2019.2.1, depending on how the project is configured, installing the Project Lombok plugin may not be sufficient. Here is another way to use Project Lombok with IntelliJ IDEA:
Visit https://projectlombok.org/download
Download the JAR file into the project lib directory (e.g., $HOME/dev/java/project/libs).
Start the IDE.
Click File 🠖 Settings.
Expand Build, Execution, Deployment 🠖 Compiler 🠖 Annotation Processors.
Ensure Enable annotation processing is checked.
Ensure Store generates sources relative to is selected based on the project's module settings (if Module output directory doesn't work, come back and try the other setting).
Click Apply.
Click Plugins.
Click Marketplace.
Set search field to: lombok
Install Lombok.
Click OK.
Restart the IDE if prompted.
Click File 🠖 Project Structure.
Select Libraries.
Click the + symbol to add a new project library (or press Alt+Insert).
Select Java.
Set the path to: $HOME/dev/java/project/libs/lombok.jar
Click OK.
Select the modules to apply.
Click OK.
Optionally, rename lombok to Project Lombok 1.18.8.
Click OK.
The project can now import from the lombok package and use Project Lombok annotations (e.g., lombok.Setter and lombok.Getter).
Picture representation of resolving this issue.
First enable annotation processors and try. This may or may not work.
Post that, you can install the lombok plugin from intellij, (After installation Intellij will restart to enable the plugin, so make sure you save your work.(Intellij does save all the changes before restart, just to be on the safe side.)) screenshot below:
Enabling annotation processing will make it work
But if you are on a Mac, make sure you enable annotation processing(tick the checkbox) from both the places available.
1.) Intellij Idea -> Preferences -> Compiler -> Annotation Processors
2.) File -> Other Settings -> Default Settings -> Compiler -> Annotation Processors
Make sure it's added correctly to your project.
example for Gradle:
dependencies {
compileOnly 'org.projectlombok:lombok:1.18.8'
annotationProcessor 'org.projectlombok:lombok:1.18.8'
...
}
Install Lombok plugin for your IDE
Check "Enable annotation processing" checkbox in IDE (IntellijIdea), have no idea if there is anything like this for other IDEs like Eclipse.
in the latest Gradle version you should use annotationProcessor:
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok:1.18.8'
I'm using IntelliJ IDEA 2020.3 (Community Edition)
Here, besides install the Lombok plugin and enable annotations (explained by other answers). I also needed to set the flag -Djps.track.ap.dependencies=false to the Build Process Option¹.
I didn't need to use the -javaagent approach, neither setup the classpath.
¹. Go to: File | Settings | Build, Execution, Deployment | Compiler | "Shared build process VM options" field
References:
https://github.com/rzwitserloot/lombok/issues/2592#issuecomment-705449860
https://youtrack.jetbrains.com/issue/IDEA-250718#focus=Comments-27-4418347.0-0
Just for reference using IntelliJ 2018.3, I solved this issue (using #Data annotation to insert getter/setter) following the three steps:
File -> Settings -> Build, Execution, Deployment -> Annotation Processors -> Enable Annotation Processing;
Do remember to Apply the change.
Install plugin lombok in the same setting dialog;
It seems good enough for now, it requires to restart IntelliJ and then rebuild your project.
Best wishes :)
If you have checked both these steps as follows
Enable annotations : this is a check done in IntelliJ
preferences.
Importing lombok into IntelliJ classPath
(Preferences -> Plugins)
and still getting errors then please check the compiler - if it is JAVAC or ECLIPSE.
You can check the compiler in Preferences -> Build,Execution,Deployment -> Compiler -> Java Compiler.
Change the Use compiler to Javac (if it is Eclipse). This is what worked for me.
Including the following in the pom.xml is what worked for me:
<build>
<defaultGoal>spring-boot:run</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<annotationProcessorPaths>
...
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</build>
As noted here, quote: "You should activate external compiler option and enable annotation processors or disable external compiler and disable all of annotation compilers to work with lombok". This fixed my problem. Note that I added the Scala plugin prior to receiving this error, so I suspect the plugin changed some of the above settings.
there is a plugin for intellij. see here: https://projectlombok.org/download.html
Do you have lombok as dependency of your project? lombok.jar must be on the classpath during compiling of the project, which is using any of lombok-annotations.
For those of you who are still having trouble:
In addition to the above steps of enabling annotation processors and installing the IntelliJ Lombok plugin, I also had to Build -> Rebuild Project.
1、install lombok plugin for IDEA
Intellij Idea -> Preferences -> Plugins -> type in lombok -> Search in Repositories -> install -> restart IDEA
2、 config lombok plugin
Enabling annotation processing will make it work
But if you are on a Mac, make sure you enable annotation processing in the following two places:
Intellij Idea -> Preferences -> Build, Execution, Deployment -> Compiler -> Annotation Processors, check the checkbox of "Enable annotation processing".
File -> Other Settings -> Default Settings -> Build, Execution, Deployment -> Compiler -> Annotation Processors, check the checkbox of "Enable annotation processing".
I was on Mac
This is my IntelliJ IDEA and Mac Version - IntelliJ IDEA 2017.1.5 Build #IU-171.4694.70 --- Mac OS X 10.12
In addition to enabling annotation processing (tick the checkbox) at these 2 places.
1.) Intellij IDEA -> Preferences -> Compiler -> Annotation Processors
.
2.) File -> Other Settings -> Default Settings -> Compiler -> Annotation Processors
I had to install Lombok plugin too to make it work.
3.) Intellij IDEA -> Preferences -> Plugins ->Browse Repositories-> Search for "Lombok"-> install plugin -> Apply and restart IDEA
It didn#t work for me with any of the above solutions. I added <scope>provided</scope> to the dependency in pom.xml and it worked.
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.20</version>
<scope>provided</scope>
</dependency>
If you already installed it, then for refresh just deselect and select Enable annotation in Intellij Settings.
I have faced this problem after updating the IDEA to 2018.3. I had to update all the existing plugin
After trying all the suggestions here, I have also find another kind of solution. It seems that sometimes IDEA can not obtain processors from project classpath.
So, on the Annotation Processors settings tab, you have to manually specify Processor path.
Apart from mentioned in all answers I have to add the below code in pom.xml configuration to makes mvn clean install work. Before adding this code I was getting cannot found symbol for getters and setters.
<annotationProcessorPath>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.8</version>
</annotationProcessorPath>
For me what worked:
I uninstalled the installed the Lombok plugin freshly
I ticked "Enable Annotation Plugin"
I selected "Obtain processor from the project classpath" in the same page
For IntelliJ IDEA 2020.1.1 enabling Kotlin plugin fixed this issue.
If you did everything mentioned in this question and It's still failing, don't forget to remove /target folder under your projects. And If it's still failing, restart your IDE.
And If it's still failing restart your computer.
The Jetbrains IntelliJ IDEA editor is compatible with lombok without a plugin as of version 2020.3.
I was using 2020.2 version, i updated to 2020.3 it worked just like that.
I don't think I read my final step in the answers yet. (Mac + IntelliJ Ultimate 2020.1)
Its just a silly cause in my case, but those are the ones that can take up most time because the error doesnt directly refer to it.
The same lombok error appeared to me after deleting and recloning the project.
After doing the steps mentioned earlier in this thread I still had the error, I then discovered my SKD was defaulted to version 11. I changed this back to 1.8 and everything worked again.
File --> Project Settings --> Project
I changed the Project SDK and the Project language level to 1.8
PS the location for the default settings on the mac is different in this IntelliJ version than mentioned before :
File --> New Project Settings --> Preferences for new Projects --> Build, Execution, Deployment --> Compiler --> Annotation Processors --> 'check' Enable annotation processing
Hope this helps anybody
If none of the above did'nt work , then try to change File->Project Structure->Project->Project Language Level > 8 Lambda,type annotations (Not SDK Default 8)
This worked for me .
I tried enabling lambok, restarted intellij, etc but below worked for me.
Intellij Preferences ->Compiler -> Shared Build process VM Options and set it to
-Djps.track.ap.dependencies=false
than run
mvn clean install
It may happen that even if you have it configured properly and it is visible among the libraries and in Gradle dependencies list, IntelliJ still does not have it in class path. Or it is there, but configured with different scope (ex: test instead of compile.)
First, make sure you have plugin installed and annotation processing enabled, as stated in other answers.
If you still have annotation not recognized, place cursor on it, hit ALT+ENTER (or OPTION+ENTER) and see if you have a menu option Add library: Gradle: org.projectlombok:lombok:VERSION to class path. If you can see it, choose this one and it may solve your problem.
You may check the library and it's scope in:
Project settings / Modules / Dependencies tab (search for lombok in there)
I had a similar issue when building with JDK8, set the project back to JDK7 and it worked fine. Could be an older version of Lombok that won't compile under JDK8.
If you tried all solutions presented here and still can't compile sources, also look here: Static import of builder class breaks bytecode generation in Maven - look at your sources if it has such static imports. This affects maven plugin, so compilation will fail on other build systems outside IntelliJ IDEA.
I am using IntelliJ IDEA 2018.2.5 (Community Edition). Here are the complete details.
Build #IC-182.4892.20, built on October 16, 2018
JRE: 1.8.0_152-release-1248-b19 amd64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Windows 10 10.0
I have followed all the suggested solutions in so many different answers in SO. but nothing worked for me.
Here are the screenshots of required setting that needs to be done for lombok package.
lombok jar is available in external libraries.
I still get the error while compiling the application.
Project Library:
I had the same problem, after change git branch in intellij.
The solution is:
on project panel (left side) right click on pom.xml file
click on "Add as Maven Project"
In my case, I forgot the test dependency:
testCompileOnly 'org.projectlombok:lombok:1.18.22'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.22'
Gradle 4.10, java1.8, Intellij Idea 2018.3.2
Try to setup the scope directly. Example for maven:
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.22</version>
<scope>compile</scope>
</dependency>
In order for intelliJ to be able to read lombok at compile time, you would have to update annotation processor settings in the IDE and then add the plugin for lombok.
Please refer to this link for details about how to do the above said changes.
I met exactly the same issue, but couldn't let it go after tried all solutions I could found in stackoverflow.
Eventually, I fixed it, by changing Preferences - Build, Execution, deployment > Build Tools > Gradle:
Build and run using: Gradle (Default) // it was Intellij IDEA
Run tests using: Gradle (Default) // it was Intellij IDEA
Gradle JVM: 11 // use 8 and above
Not sure if this is the right answer, but any of you have this issue can try. I believe it's just the IntelliJ setting caused problem.
Check out this link: https://projectlombok.org/setup/gradle
I had the same problem and resolved it after adding lombok dependencies in build.gradle
for me:
I downmoad "lombok.jar" for origine site "https://projectlombok.org/download".
in intellij IDE, File => Preject Structure => Librairies.
click to button "+" to add librairies => java => file "lombok.jar"
that's works for me
I keep getting this error when I try to compile my code. I have the pom.xml file in my directories but I am not sure if there is something wrong in there. I found only one link on the internet regarding this and that was not my case: Maven project configuration required for module
Error:Maven Resources Compiler: Maven project configuration required for module 'updater' isn't available. Compilation of Maven projects is supported only if external build is started from an IDE.
Here is the content of my pom file:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.nothing.updater</groupId>
<artifactId>Updater</artifactId>
<version>1.0-SNAPSHOT</version>
<!--<dependencies>-->
<!--<dependency>-->
<!--<groupId>com.nothing.toolbox</groupId>-->
<!--<artifactId>Toolbox</artifactId>-->
<!--<version>1.1</version>-->
<!--</dependency>-->
<!--</dependencies>-->
</project>
I am using a multi-module project.
Right-click on pom.xml and then click on "Add as Maven Project".
Right click the module and select the Make Module "project module name" option from the pop up menu. The messages will be shown. But go to Problems and see now. This will clear and correct this problem.
In my case the problem ocurred after uprgrading IJ from 14.x to 15.x and disappeared when I issued Build -> Rebuild Project
In case of IntelliJ , Right click on the POM.xml file of your project and click on the option "Add as Maven Project".
My problem with this error under 2019.3.4 is related to the build delegating to Maven. Idea is letting Maven build my project first and that build is failing because I broke a test. I get around this problem by not allowing IDEA to delegate to Maven. On Mac OS Catalina: Intellij -> Preferences -> Build, Execution, Deployment -> Build Tools -> Runner and uncheck Delegate IDE Build/run actions to Maven
The messages originates from Line 43 in /org/jetbrains/jps/maven/compiler/MavenResourcesBuilder.java, so my guess is that it is no pom.xml issue but rather IntelliJ Idea related.
If you dig further into the code, it looks for a file called maven/configuration.xml and from what I see, it searches in some temporary directory.
Maybe you should try and start your build as clean as possible.
Quick solution (IntelliJ IDEA):
Right-click on the project, the select Maven->Reimport
In my case, I had to use the following trick:
Right click the module name in the project panel
Select "Open Module Settings"
In the pop-up window, click Dependencies
Select java version 1.8.0_151
I have the same error after a Intellij Idea version upgrade (2016.3 to 2017.1):
Error:Maven Resources Compiler: Maven project configuration required
for module 'MODULE_NAKE' isn't available. Compilation of Maven
projects is supported only if external build is started from an IDE.
But my solution was another. Somehow, I think the Intellij lost the maven version used in my project. I was using maven 2.2.1 but Intellij was trying to use maven 3.x.
So, my solution was adjust this configuration in:
File > Settings > Build, Execution, Deployment > Build Tools > Maven
And set the maven version to 2.2.1.
I had this problem after an Intellij Idea version upgrade. The fix was to wait for it to finish indexing. Then I think it downloaded some stuff it needed.
Makes me think that the other answers on this thread about the IJ version upgrade probably just needed to wait as well - by the time they finished trying a few things the problem was fixed by itself.
In my case this was caused by a misconfiguration of IntelliJ. A long time ago I had been experimenting with the Lifecycle options within the Maven Projects view and had left a few phases in a sub module checked as Execute Before Build.
Because I had completely forgotten having checked these, it took me quite some time to understand the connection with the error messages in the Problems view. After unchecking the Execute Before Build switches of the affected phases everything went back to normal and particularly running unit tests became much faster.
In my case, I invalidated the cache and restarted the IDE. It worked, not sure why though.
I chose the bundled maven installation which helped me.
It could also be something to do with using a symlink to reference the maven installation..
it turns out the version of intelliJ I use (2018.3) can't import maven projects using apache-maven-3.6.2
modify .idea/compiler.xml,add config(should change module name to yourself):
In my case I got this error message, because my Maven configuration in IntelliJ was broken. I had entered invalid options into VM options for importer at Preferences:Build,Execution,Deployment->Build Tools->Maven->Importing.
After deleting these options IntelliJ started to behave normal again.
I am using IDEA with WSL2 and Windows10.
My problem occurred when IDEA automatically set the JDK in WSL2 as project JDK.
After Setting my JDK back to Windows JDK, the error disappearred.
In my case I had all configured to execute the hot reload with devtools after each file change namely:
File -> Settings -> Build, Execution, Deployment -> Compiler -> Enable "Build project automatically";
File -> Settings -> Advanced Settings -> Allow auto-make to start even if developed application is currently running.
The maven related error in the Auto-build tab was being displayed and only went away when I deleted .idea folder in the root directory, opened the project again, built the project without maven config (build as Ant project), and configured all again.
After the reset the error disappeared and the maven build was executed without errors.
I was troubled by this problem all afternoon,the solution in stackoverflow is not usefull for me.But I just solved this problem by accident,i don't kown how it worked,but it is effective.If you have the same project structure.
project structure
you can try this
try this button
and you will found all children project is build success. then you can run all project normally.
Go to event log and from there you will see options, what need to fix it
This question already has answers here:
Can't compile project when I'm using Lombok under IntelliJ IDEA
(43 answers)
Closed 3 years ago.
I've installed the plugin for intellij idea(lombok-plugin-0.8.6-13).
Added lombok.jar into classpath
I can find getters and setters in the window of structure. And Intellij shows no error.
Setting - Lombok plugin - Verified Intellij configuration for lombok, it shows that "configuration of IntelliJ seems to be ok".
It seems everything is OK. But when I compile a test, errors come: can not find the methods getXXX and setXXX.
I opened the .class file with IntelliJ and find out that there is no setXXX and getXXX methods.
Could somebody tell me why?
plugin:lombok-plugin-0.8.6-13
lombok.jar:1.14.0
idea:13.0.2 for linux
jdk:1.7.0_21
In order to solve the problem set:
Preferences (Ctrl + Alt + S)
Build, Execution, Deployment
Compiler
Annotation Processors
Enable annotation processing
Make sure you have the Lombok plugin for IntelliJ installed!
Preferences -> Plugins
Search for "Lombok Plugin"
Click Browse repositories...
Choose Lombok Plugin
Install
Restart IntelliJ
If you're using Eclipse compiler with lombok, this setup finally worked for me:
IDEA 14.1
Lombok plugin
... / Compiler / Java Compiler > Use Compiler: Eclipse
... / Compiler / Annotation Processors > Enable annotation processing: checked (default configuration)
... / Compiler > Additional build process VM options:(Shared build process VM options) -javaagent:lombok.jar
The most important part is the last one, mine looks like following:
Plugin is needed for IntelliJ editor to recognize getters and setters, javaagent is needed for eclipse compiler to compile with lombok.
If you're using Intellij on Mac, this setup finally worked for me.
Installations: Intellij
Go to Preferences, search for Plugins.
Type "Lombok" in the plugin search box. Lombok is a non-bundled plugin, so it won't show at first.
Click "Browse" to search for non-bundled plugins
The "Lombok Plugin" should show up. Select it.
Click the green "Install" button.
Click the "Restart Intellij IDEA" button.
Settings:
Enable Annotation processor
Go to Preferences -> Build, Execution,Deployment -->Preferences -> Compiler -> Annotation Processors
File -> Other Settings -> Default Settings -> Compiler -> Annotation Processors
Check if Lombok plugin is enabled
IntelliJ IDEA-> Preferences -> Other Settings -> Lombok plugin -> Enable Lombok
Add Lombok jar in Global Libraries and project dependencies.
File --> Project Structure --> Global libraries (Add lombok.jar)
File --> Project Structure --> Project Settings --> Modules --> Dependencies Tab = check lombok
Restart Intellij
I followed this procedure to get ride of a similar/same error.
mvn idea:clean
mvn idea:idea
After that I could build both from the IDE intellij and from command line.
For me, both lombok plugin and annotation processing enable needed, no else. No need to Use Eclipse and additional -javaagent:lombok.jar options.
Idea 14.1.3, build 141.1010
Lombok plugin[Preference->plugins->browse repositories->search 'lombok'->install and restart idea.
Preference ->search 'annotation'->enter annotation processor ->enable annotation processing.
After spending far too long troubleshooting this, I found a simple workaround which ensures IntelliJ processes Lombok annotations correctly during builds.
The gradle-lombok plugin is not necessary for this workaround. Your build.gradle only requires the following:
dependencies {
compileOnly("org.projectlombok:lombok:1.16.18")
}
The workaround is to turn on the following IntelliJ setting:
Open IntelliJ preferences/settings.
Navigate to Build, Execute, Deployment > Build Tools > Gradle > Runner
Check the box labeled Delegate IDE build/run actions to gradle
Benefits of this workaround compared to other solutions on this page:
No annotation processing necessary!
Able to use the Java compiler of your choice (no Eclipse compiler necessary)
No use of buggy gradle-lombok plugin (although perhaps someone else can solve this)
No VM options necessary
No hard-coded paths to lombok jar
One downside is that IntelliJ will no longer use its own test runner. Instead, tests are always run through Gradle.
IDEA 2016.1:
Install lombok plugin
Settings -> Compiler -> Annotation Processors -> Enable annotation processing: checked (default configuration)
Settings -> Compiler -> Annotation Processors -> Annotation Processors add "lombok.launch.AnnotationProcessorHider$AnnotationProcessor"
Also if you are using maven add to maven-compiler-plugin configuration -> annotationProcessors -> annotationProcessor: lombok.launch.AnnotationProcessorHider$AnnotationProcessor
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven.plugin.compiler.version}</version>
<configuration>
<compilerVersion>${java.version}</compilerVersion>
<source>${java.version}</source>
<target>${java.version}</target>
<annotationProcessors>
<annotationProcessor>lombok.launch.AnnotationProcessorHider$AnnotationProcessor</annotationProcessor>
</annotationProcessors>
</configuration>
</plugin>
Make sure these two requirements are satisfied:
Enable annotation processing,
Preferences > Build, Execution, Deployment > Compiler > Annotation Processors > Enable annotation processing
Lombok plugin is installed and enabled for your project.
None of the advanced answers to this question resolved the problem for me.
I managed to solve the problem by adding a dependencie to lombok in the pom.xml file, i.e. :
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.12</version>
</dependency>
I am using IntelliJ 2016.3.14 with maven-3.3.9
Hope my answer will be helpful for you
On Itellij 15 CE, it's enough to just install Lombok Plugin (no additional configuration required).
I am unable to get this working with the javac compiler, and I get the same error.
Error:(9, 14) java: package lombok does not exist
I have enabled annotation processor, and have also tried rebuilding the project, invalidate cache/restart. Doesn't help.
I did however get it to work partially with eclipse compiler. I say partial because although the build passes successfully, the editor still complains about "Cannot resolve symbol".
Idea - 15.04 community edition
Lombok - 1.16.6
Lombok plugin (https://github.com/mplushnikov/lombok-intellij-plugin) - 0.9.8
JDK - 1.8.0_51
Update:
Ok, I finally got this working. Mine was a gradle project, and lombok was configured as a custom "provided" configuration. Worked fine after adding this in build.gradle
idea {
module {
scopes.PROVIDED.plus += [configurations.provided]
}
}
So, 3 steps
Install Lombok plugin from File->Settings->Plugins
Enable Annotation Processor (javac compiler works too)
Ensure that you have build.gradle or pom.xml updated for idea if you are adding lombok as a custom config.