apache / netbeans

Apache NetBeans
https://netbeans.apache.org/
Apache License 2.0
2.65k stars 850 forks source link

NetBeans22: Lombok can not work correctly #7664

Closed berrychiao closed 2 months ago

berrychiao commented 2 months ago

Apache NetBeans version

Apache NetBeans 22

What happened

In DLeans22, I have a Maven project that introduced the Lombok plugin and used the @ getter annotation. However, when using the getXXX method, an error message appears: Method not found.

Language / Project Type / NetBeans Component

Java Maven Web 应用程序项目

How to reproduce

In DLeans22, I have a Maven project that introduced the Lombok plugin and used the @ getter annotation. However, when using the getXXX method, an error message appears: Method not found.

Maven:3.9.7

Did this work correctly in an earlier version?

No / Don't know

Operating System

win11

JDK

JDK17

Apache NetBeans packaging

Apache NetBeans provided installer

Anything else

<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">

4.0.0
<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.7.13</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>serveBoot</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>serveBoot</name>
<description>serveBoot</description>
<properties>
    <java.version>1.8</java.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
        <groupId>org.mybatis.spring.boot</groupId>
        <artifactId>mybatis-spring-boot-starter</artifactId>
        <version>2.3.1</version>
    </dependency>

    <dependency>
        <groupId>com.mysql</groupId>
        <artifactId>mysql-connector-j</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <version>1.18.28</version>          
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.mybatis.spring.boot</groupId>
        <artifactId>mybatis-spring-boot-starter-test</artifactId>
        <version>3.0.3</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.github.pagehelper</groupId>
        <artifactId>pagehelper-spring-boot-starter</artifactId>
        <!--            <version>1.2.13</version>-->
        <version>1.4.1</version>
    </dependency>
</dependencies>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <configuration>
                <annotationProcessorPaths>
                    <path>
                        <groupId>org.projectlombok</groupId>
                        <artifactId>lombok</artifactId>
                        <version>1.18.24</version>
                    </path>
                </annotationProcessorPaths>
            </configuration>
        </plugin>
    </plugins>
</build>
<repositories>
    <repository>
        <id>nexus-aliyun</id>
        <name>nexus-aliyun</name>
        <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </repository>
</repositories>

<pluginRepositories>
    <pluginRepository>
        <id>public</id>
        <name>aliyun nexus</name>
        <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>false</enabled>
        </snapshots>
    </pluginRepository>
</pluginRepositories>

Are you willing to submit a pull request?

Yes

berrychiao commented 2 months ago

I have already resolved the issue of listing the contents of pom.xml。

image image

maven: v3.9.7 netBean: 22 JDK:17

berrychiao commented 2 months ago

But for some reason, I used the above version of Lombok in pom.xml and it was not downloaded correctly. NetBeans showed that I needed to rebuild the project, and when I rebuilt the project, Lombok was able to work properly. So, I suggest that when [number # 7664] appears( https://github.com/apache/netbeans/issues/7664 )When encountering issues, first rebuild the project, especially for migrating to netBeans. If it doesn't work, try the above version again.

matthiasblaesing commented 2 months ago

The general advice from my POV for lombok users is: Evaluate whether lombok brings enough to the table to warrant the pain you'll receive. It reaches deeply into the javac and has a high chance to break on JDK updates. If you decide to still use lombok, keep it current, always. You might even need unreleased versions.