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

java - Spring Boot App doesn't run in IntelliJ with Lombok - Stack Overflow

programmeradmin3浏览0评论

I know this question before, BUT when the questioned was asked, it was years ago, and the fix then might not be the fix now. Believe me when I tell you I did my research on this before coming here.
I have the latest IntelliJ installed '2024.1.7', I have the Lombok Plugin installed in IntelliJ, and I updated my pom.xml to include the version of Lombok (1.18.36) for the dependency. I also have the Annotation Processing turned on for the build process. All these I have seen from previous posts, so I wonder what could be going wrong.

This application ran perfectly with Lombok under Eclipse and STS. This application uses the maven: mvn clean install -U and runs perfectly. The app builds in IntelliJ with Lombok, and all the tests run. Now I want to run this Spring Boot app in IntelliJ and I get 6 errors that all stem from not being able to find the getters or setters.

java: cannot find symbol
symbol:   method setCompanyId(java.lang.Long)
location: variable company of type com.product.htmx.demo.model.CompanyEntity

CompanyEntity is defined as follows:

@Data
@With
@NoArgsConstructor
@AllArgsConstructor
@SuppressWarnings("serial")
@Entity
@Table(name = "company")
public class CompanyEntity implements Serializable {
    // `company_id` int NOT NULL AUTO_INCREMENT,
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "company_id")
    private Long companyId;

I get the same error "cannot find symbol" with 5 other classes. However, the other entities and DTO's have multiple properties, and yet I don't get the same error message. I know this might seem like a duplicate message, but I know this is not the same fix as the other much older messages.

I know this question before, BUT when the questioned was asked, it was years ago, and the fix then might not be the fix now. Believe me when I tell you I did my research on this before coming here.
I have the latest IntelliJ installed '2024.1.7', I have the Lombok Plugin installed in IntelliJ, and I updated my pom.xml to include the version of Lombok (1.18.36) for the dependency. I also have the Annotation Processing turned on for the build process. All these I have seen from previous posts, so I wonder what could be going wrong.

This application ran perfectly with Lombok under Eclipse and STS. This application uses the maven: mvn clean install -U and runs perfectly. The app builds in IntelliJ with Lombok, and all the tests run. Now I want to run this Spring Boot app in IntelliJ and I get 6 errors that all stem from not being able to find the getters or setters.

java: cannot find symbol
symbol:   method setCompanyId(java.lang.Long)
location: variable company of type com.product.htmx.demo.model.CompanyEntity

CompanyEntity is defined as follows:

@Data
@With
@NoArgsConstructor
@AllArgsConstructor
@SuppressWarnings("serial")
@Entity
@Table(name = "company")
public class CompanyEntity implements Serializable {
    // `company_id` int NOT NULL AUTO_INCREMENT,
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "company_id")
    private Long companyId;

I get the same error "cannot find symbol" with 5 other classes. However, the other entities and DTO's have multiple properties, and yet I don't get the same error message. I know this might seem like a duplicate message, but I know this is not the same fix as the other much older messages.

Share Improve this question asked Mar 15 at 21:56 tjholmes66tjholmes66 2,0204 gold badges44 silver badges79 bronze badges 4
  • Are you using JDK 23 to run the application with IntelliJ by any chance? If so, please see Build Failure: @Data Annotation won't regonize by Maven Specifically, please check the part about <proc>full</proc>. – dan1st Commented Mar 15 at 22:59
  • @dan1st Your answer didn't work for me, so I posted my answer which worked for me somehow. – Remzi Cavdar Commented Mar 15 at 23:47
  • I did have JDK 23 installed even though on Windows 11 I set up the environmental values for JDK 21. I removed JDK 23 altogether to avoid any confusion. So, far this did not remove the issue. – tjholmes66 Commented Mar 15 at 23:58
  • As the OP confirmed it, I am hereby voting to mark this as a duplicate of Build Failure: @Data Annotation won't regonize by Maven. – dan1st Commented Mar 16 at 9:20
Add a comment  | 

1 Answer 1

Reset to default 2

What worked for me is to put the following into Build in my pom.xml:

<build>
        <plugins>
            <plugin>
                <groupId>.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>.projectlombok</groupId>
                <artifactId>lombok-maven-plugin</artifactId>
                <version>1.18.20.0</version>
                <executions>
                    <execution>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>delombok</goal>
                        </goals>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>.projectlombok</groupId>
                        <artifactId>lombok</artifactId>
                        <version>${lombok.version}</version>
                    </dependency>
                </dependencies>
            </plugin>
            <plugin>
                <groupId>.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven-compiler-plugin.version}</version>
                <configuration>
                    <annotationProcessorPaths>
                        <path>
                            <groupId>.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                            <version>${lombok.version}</version>
                        </path>
                    </annotationProcessorPaths>
                </configuration>
            </plugin>
        </plugins>
    </build>
发布评论

评论列表(0)

  1. 暂无评论