Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] 'Symbol' not recognized. Getters and Setters. #3804

Open
patrickfeeney03 opened this issue Jan 1, 2025 · 8 comments
Open

[BUG] 'Symbol' not recognized. Getters and Setters. #3804

patrickfeeney03 opened this issue Jan 1, 2025 · 8 comments

Comments

@patrickfeeney03
Copy link

patrickfeeney03 commented Jan 1, 2025

Describe the bug
Getters and setters are not being created. Seems to work fine until compilation. If I comment out a plugin in the Pom file the issue goes away. This has happened to other colleagues recently (last week).

To Reproduce
Create a Spring project with Maven and Java 21. With dependencies Spring Boot DevTools, Lombok, Spring Web, JDBC API, Spring Data JPA, MySQL Driver, Spring for RabbitMQ, Validation, CycloneDX SBOM support, Cloud Bootstrap, OpenFeign.
This is the Pom that I am using. You can see the commented out lines. If I don't do this I will get errors saying java: cannot find symbol symbol: method getName(). For all of setters and getters that are supposed to be created with Lombok @DaTa
Usage example: user.setName(signUpRequest.getName());

<?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">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.4.1</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>ie.atu</groupId>
    <artifactId>auth-service</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>auth-service</name>
    <description>auth-service</description>
    <url/>
    <licenses>
        <license/>
    </licenses>
    <developers>
        <developer/>
    </developers>
    <scm>
        <connection/>
        <developerConnection/>
        <tag/>
        <url/>
    </scm>
    <properties>
        <java.version>21</java.version>
        <spring-cloud.version>2024.0.0</spring-cloud.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-amqp</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-jdbc</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-validation</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-openfeign</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>com.mysql</groupId>
            <artifactId>mysql-connector-j</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.amqp</groupId>
            <artifactId>spring-rabbit-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${spring-cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
<!--            <plugin>-->
<!--                <groupId>org.apache.maven.plugins</groupId>-->
<!--                <artifactId>maven-compiler-plugin</artifactId>-->
<!--                <configuration>-->
<!--                    <annotationProcessorPaths>-->
<!--                        <path>-->
<!--                            <groupId>org.projectlombok</groupId>-->
<!--                            <artifactId>lombok</artifactId>-->
<!--                        </path>-->
<!--                    </annotationProcessorPaths>-->
<!--                </configuration>-->
<!--            </plugin>-->
            <plugin>
                <groupId>org.cyclonedx</groupId>
                <artifactId>cyclonedx-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <configuration>
                    <excludes>
                        <exclude>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                        </exclude>
                    </excludes>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

Expected behavior
I expected that after creating the project using the generation provided by Intellij I would be able to use the setters and getters from Lombok. I did not manually modify the POM.

@patrickfeeney03
Copy link
Author

image

@sabaja
Copy link

sabaja commented Jan 5, 2025

Here I'm with same problem as @patrickfeeney03, I tried several projects with spring boot 3.4.1, java 21, maven h2/postgres/mysql, jpa/hibernate, kafka and so on.. but org.projectlombok:lombok:1.18.36 is no longer working properly.
During compile time everything seems ok, but at runtime time the exception cannot find the symbol
image

@patrickfeeney03
Copy link
Author

Here I'm with same problem as @patrickfeeney03, I tried several projects with spring boot 3.4.1, java 21, maven h2/postgres/mysql, jpa/hibernate, kafka and so on.. but lombok is no longer working properly.
During compile time everything seems ok, but at runtime time the exception cannot find the symbol
image

Try commenting out what I commented out in my pom. May help you. For now ...

@dinmukhamed1729
Copy link

dinmukhamed1729 commented Jan 10, 2025

Это сработало, но не уверен, почему именно. Возможно, дело в зависимости или конфигурации, которую я добавил, но я не разбирался в этом глубже.
Вот как я сделал:

    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <scope>annotationProcessor</scope>
    </dependency>
    

@khanhoit
Copy link

you need set detail version of lombok and add dependency lombok detail
image

@patrickfeeney03
Copy link
Author

you need set detail version of lombok and add dependency lombok detail image

yeah buy why would you need to specify the version. The project creation tool is supposed to handle all of this.

@hfyZone
Copy link

hfyZone commented Jan 16, 2025

I have the same problem.And my project uses idk 17, when I run 'mvn clean install' ,all the getters and setters can't be found.i tried everything on the web but none of them are helpful.I am afraid I have to use jkd1.8 and springboot2 for a probably well functioned Lombok or just write all the getters and setters by myself 😭

@patrickfeeney03
Copy link
Author

I have the same problem.And my project uses idk 17, when I run 'mvn clean install' ,all the getters and setters can't be found.i tried everything on the web but none of them are helpful.I am afraid I have to use jkd1.8 and springboot2 for a probably well functioned Lombok or just write all the getters and setters by myself 😭

try to do what I did. It's at the very top of this, in the pom file. lmk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants