Maven build cannot find symbol when accessing project lombok annotated methods,
I have downgraded the lombok to 1.14.8 this version works with maven build, I havent found why the 1.16 verson is not working :(
[ERROR]: cannot find symbol variable log when building with maven and lombok
This is a really minimal example configuration for using the @Slf4j
lombok logging annotation.
You need a logging facade and an implementation, in this case I'm going to use slf4j (as facade) and logback (as implementation).
pom.xml
<?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>org.example</groupId>
<artifactId>untitled</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.12</version>
<scope>provided</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.30</version>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>1.2.3</version>
</dependency>
</dependencies>
</project>
main.java
import lombok.extern.slf4j.Slf4j;
@Slf4j
public class Main {
public static void main(String[] args) {
log.debug("Hello");
}
}
If you get some trouble try always to force the maven dependencies updates running in your project folder mvn -U clean package
and reimporting maven project in your IDE
Application build failed cause of Lombok
This issue has been resolved in a newer version of Lombok. Please update the Lombok version to 1.18.18 and it will fix the issue.
Can't compile project when I'm using Lombok under IntelliJ IDEA
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
toProject 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
).
Lombok not compiling in maven
I don't know why but you got compiler error because of maven-compiler-plugin. If you can please change plugin version to 3.5 and check if it will work.
Related Topics
How to Upload a File and Json Data in Postman
What Happens When Base and Derived Classes Each Have Variables With the Same Name
How to Get All Keys from a Json-Object as a String Array in Java
Spring Rest - Create Zip File and Send It to the Client
How to Get Numbers from Given Gcd and Lcm
Java:Using Apache Poi How to Convert Ms Word File to Pdf
Springboot Data - No Property Registration Found
How to Handle Incorrect User Input into a Scanner
Connection Java - Mysql:Public Key Retrieval Is Not Allowed
Multipartexception: Current Request Is Not a Multipart Request
Resttemplate: How to Send Url and Query Parameters Together
How to Check Whether an Array Is Null/Empty
How to Store a String Longer Than 4000 Characters in an Oracle Database Using Java/Jdbc
How to Get All Members of Ad Group Via Ldap in Java
How to Download Entire Folder Located on S3 Bucket
How to Put a Scanner Input into an Array... for Example a Couple of Numbers
How to Get a List of All the Implementations of an Interface Programmatically in Java