最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

spring boot maven plugin - Lombok doesn't work in newer version SpringBoot 3.4.1 - Stack Overflow

programmeradmin1浏览0评论

Lombok doesn't work in SpringBoot 3.4.1. but IntelliJ IDE doesn't show any errors. But during compile time, every code that generates from Lombok getting notFound() error. I tried every possible solution:

  • Invalidating caches and restart IDE.
  • Try different versions of Lombok.
  • Deleting .m2 file.
  • Reclone repository.
  • Regenerated mvn files.
  • Finally reinstalled IDE also. Nothing make difference.

But in SpringBoot 3.3.4 Lombok works fine.

Lombok doesn't work in SpringBoot 3.4.1. but IntelliJ IDE doesn't show any errors. But during compile time, every code that generates from Lombok getting notFound() error. I tried every possible solution:

  • Invalidating caches and restart IDE.
  • Try different versions of Lombok.
  • Deleting .m2 file.
  • Reclone repository.
  • Regenerated mvn files.
  • Finally reinstalled IDE also. Nothing make difference.

But in SpringBoot 3.3.4 Lombok works fine.

Share Improve this question edited Jan 18 at 12:24 Roar S. 11.4k1 gold badge18 silver badges50 bronze badges asked Jan 18 at 11:12 Sena.DSena.D 12 bronze badges 0
Add a comment  | 

1 Answer 1

Reset to default 0

I ran into the same issue today with a new Spring Boot project created in IDEA. My Lombok annotations stopped working. Here's the error I encountered: I used the @Data annotation on the User class, but the corresponding getName() method was not generated.

java: 找不到符号
  符号:   方法 getName()
  位置: 类型为com.nx.nxapiapi.model.User的变量 user

After trying a few things, I found that the project only works if I comment out the optional tag for Lombok in the pom.xml and the first plugin in the <build> section. Here's how my pom.xml looks now:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache./POM/4.0.0" xmlns:xsi="http://www.w3./2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache./POM/4.0.0 https://maven.apache./xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.4.1</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.nx</groupId>
    <artifactId>NXApi-api</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>NXApi-api</name>
    <description>NXApi-api</description>
    <url/>
    <licenses>
        <license/>
    </licenses>
    <developers>
        <developer/>
    </developers>
    <scm>
        <connection/>
        <developerConnection/>
        <tag/>
        <url/>
    </scm>
    <properties>
        <java.version>17</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>.projectlombok</groupId>
            <artifactId>lombok</artifactId>
<!--            <optional>true</optional>-->
        </dependency>
        <dependency>
            <groupId>.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

    <build>
        <plugins>
<!--            <plugin>-->
<!--                <groupId>.apache.maven.plugins</groupId>-->
<!--                <artifactId>maven-compiler-plugin</artifactId>-->
<!--                <configuration>-->
<!--                    <annotationProcessorPaths>-->
<!--                        <path>-->
<!--                            <groupId>.projectlombok</groupId>-->
<!--                            <artifactId>lombok</artifactId>-->
<!--                        </path>-->
<!--                    </annotationProcessorPaths>-->
<!--                </configuration>-->
<!--            </plugin>-->
            <plugin>
                <groupId>.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>
                            <groupId>.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                        </exclude>
                    </excludes>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>
发布评论

评论列表(0)

  1. 暂无评论