Annotations not generated in Eclipse IDE

96 Views Asked by At

I'm struglling with annotations in Eclipse since no annotation generates code. I tried several solutions:

  1. Checking the "Enable annotation processing" under Annotation Processing in Java Compiler in the project properties
  2. Creating a new Maven project (Java 17 with 2 dependencies: Lombok and log4j only)
  3. Followed the directions in this tutorial Eclipse getting started with AP
  4. several mvn clean intalls, eclipse clean project, closing and reopening the IDE ...

here is my pom

<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.annot</groupId>
<artifactId>annotations</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>annotations</name>
<properties>
    <java.version>17</java.version>
    <maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>
<dependencies>
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <version>1.18.24</version>
        <scope>provided</scope>
    </dependency>
    <!-- https://mvnrepository.com/artifact/log4j/log4j -->
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.17</version>
    </dependency>

</dependencies>

<build>
<plugins>
    <plugin>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.1</version>  
        <configuration>
            <annotationProcessorPaths>
                <path>
                    <groupId>org.projectlombok</groupId>
                    <artifactId>lombok</artifactId>
                    <version>1.18.24</version> 
                </path>
            </annotationProcessorPaths>
        </configuration>
    </plugin>
</plugins>

here is an example class containing two lombok annotation and the outline (showing that no method was generated) enter image description here The annotation Processing window in Java Compiler in the project properties enter image description here

neither the constructor is recognized nor the @log4j annotation generates the appropriate logger

The factory path enter image description here

I'm used to use annotations in java projects with eclipse but i never encountered this problem. Any idea to solve this? thanks

1

There are 1 best solutions below

3
Sandeepan Banerjee On BEST ANSWER

Do this steps :

  • Download the Lombok JAR file from https://projectlombok.org/download.
  • Open a command prompt (CMD) and navigate to the directory where the Lombok JAR file is located.
  • Run the following command:

java -jar <Your_jar_name.jar>

.

  • If the installer does not automatically find Eclipse, you may need to manually specify the Eclipse installation path when prompted.
  • After successfully installing Lombok, you can verify the installation by checking the "Help" > "About" section in Eclipse. The Lombok version details should be visible there if the installation was successful.

https://projectlombok.org/setup/eclipse