1

My project is a Spring-boot 2.1.1.RELEASE application. It's a multi-module maven project. This is the Parent POM file

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

    <name>example-parent</name>
    <description>example.com parent module</description>

    <groupId>com.example</groupId>
    <artifactId>example-parent</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>pom</packaging>

    <modules>
        <module>example-common</module>
        <module>example-persistence</module>
        <module>example-rest</module>
    </modules>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.1.1.RELEASE</version>
    </parent>

    <build>
        <plugins>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
            </plugin>

        </plugins>

        <pluginManagement>
            <plugins>

                <plugin>
                    <groupId>org.apache.maven.plugins</groupId>
                    <artifactId>maven-compiler-plugin</artifactId>
                    <version>${maven-compiler-plugin.version}</version>
                    <configuration>
                        <source>${java-version}</source>
                        <target>${java-version}</target>
                        <compilerArgument>-proc:none</compilerArgument>
                    </configuration>
                </plugin>

            </plugins>
        </pluginManagement>

    </build>

    <properties>
        <maven-compiler-plugin.version>3.7.0</maven-compiler-plugin.version>
        <java-version>1.8</java-version>
    </properties>

</project>

The example-common uses lambok annotation for getters and setters. Here is the POM file of example-common

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

    <parent>
        <groupId>com.example</groupId>
        <artifactId>example-parent</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>
    <artifactId>example-common</artifactId>
    <name>example-common</name>
    <description>module contains commons utils for all other modules</description>

    <dependencies>

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

        <!-- other dependencies -->

    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <source>${java-version}</source>
                    <target>${java-version}</target>
                    <compilerArgument>-proc:none</compilerArgument>
                    <annotationProcessorPaths>
                        <path>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                            <version>${lombok.version}</version>
                        </path>
                    </annotationProcessorPaths>
                </configuration>
            </plugin>

        </plugins>
    </build>

</project>

As one can see, I am using <annotationProcessorPaths>.

@Data
public class CaptchaConfigs {

    private String site;
    private String secret;

}

@Data annotation is not generating getters/setters during the maven build process and hence giving the error

cannot find symbol [ERROR] symbol:   method getSite()
cannot find symbol [ERROR] symbol:   method getSecret()

The getters/setters are present in the IDE, I can see them in outline window. outline window showing generated methods

If I remove the @Data and write the getters/setters manually, the BUILD succeed.

I have done every configuration(lambok-xxx.jar) for lambok and that's why it's not giving the compilation error in the IDE, it fails only at BUILD.

Am I doing something wrong at POM?

PS: I am using eclipse STS version: 3.9.6.RELEASE

The Coder
  • 3,447
  • 7
  • 46
  • 81

4 Answers4

0

enter image description here select Third option and try if not work you follow the below link might help

answer somehow related to your issue click on the link

abhinavsinghvirsen
  • 1,853
  • 16
  • 25
  • Already tried. The link you provided, have the solutions if the IDE is not generating the methods. But in my case, I can see the getters/setters in the outline window. They are not present only at the build time. Added the image in the question. – The Coder Mar 19 '19 at 12:18
0

Please define maven-compiler-plugin version to 3.5. With maven compiler 3.5.x annotationProcessorPaths, works fine.

Try adding below to your maven compiler plugin.

<version>3.5.1</version>
Rmahajan
  • 1,311
  • 1
  • 14
  • 23
0

I am using Lombok on same Spring Boot 2.1.1.RELEASE. I think the problem is with your maven plugin. Below is my dependency and plugin which works fine.

<dependency>
    <groupId>org.projectlombok</groupId>
    <artifactId>lombok</artifactId>
    <optional>true</optional>
</dependency>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>
UsamaAmjad
  • 4,175
  • 3
  • 28
  • 35
0

It was my configuration, as I expected. Got the answer from here.

Maven compiler not adding getters/setters(generated using Lombok) to the build jar file

Actually it was the <compilerArgument>-proc:none</compilerArgument> which caused the issue. Removing it solved the issue.

The Coder
  • 3,447
  • 7
  • 46
  • 81