Lombok Builder not find in maven compilation

Viewed 838

I'm trying to create a static method in order to ease the builder usage and return the created builder to continue creating the object if it's needed:

@Data
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class Foo {

    private String submit;

    private String modify;

    public static Foo.FooBuilder ofSubmit(String submit) {

        return Foo.builder()
                .submit(submit);
    }

}

In IntelliJ works properly but when I compile with maven I get next error:

diagnostic: /src/main/java/com/Foo.java:33: error: cannot find symbol
    public static Foo.FooBuilder ofSubmit(String pan,
                     ^
  symbol:   class FooBuilder
  location: class com.Foo

I'm using Lombok 1.18.20

Any idea?

//EDIT

Include the maven configuration:

maven-compiler-plugin whit mapstruct compatibility configuration:

<plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.1</version>
                <configuration>
                    <source>${java.version}</source>
                    <target>${java.version}</target>
                    <annotationProcessorPaths>
                        <path>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                            <version>${org.projectlombok.version}</version>
                        </path>
                        <!-- This is needed when using Lombok 1.18.16 and above -->
                        <path>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok-mapstruct-binding</artifactId>
                            <version>0.2.0</version>
                        </path>
                        <!-- Mapstruct should follow the lombok path(s) -->
                        <path>
                            <groupId>org.mapstruct</groupId>
                            <artifactId>mapstruct-processor</artifactId>
                            <version>${org.mapstruct.version}</version>
                        </path>
                    </annotationProcessorPaths>
                </configuration>
            </plugin>
1 Answers

I was searching like you. I had "Cannot find symbol" while making a "clean install" with maven whereas i had configured well my Intellij as suggested in Plugins-->Compiler-->Annotations--> Activate Annotation Processors.

Finally, i noticed in you post that i was using like Mapstruct but i had added lombo plugin separately in my pom.xml.

And now i configured like this and it works fine :

<plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.8.1</version>
            <configuration>
                <source>1.8</source> <!-- depending on your project -->
                <target>1.8</target> <!-- depending on your project -->
                <encoding>UTF-8</encoding>
                <annotationProcessorPaths>
                    <path>
                        <groupId>org.projectlombok</groupId>
                        <artifactId>lombok</artifactId>
                        <version>${lombok.version}</version>
                    </path>
                    <!-- This is needed when using Lombok 1.18.16 and above -->
                    <path>
                        <groupId>org.projectlombok</groupId>
                        <artifactId>lombok-mapstruct-binding</artifactId>
                        <version>0.2.0</version>
                    </path>
                    <path>
                        <groupId>org.mapstruct</groupId>
                        <artifactId>mapstruct-processor</artifactId>
                        <version>${org.mapstruct.version}</version>
                    </path>
                    <!-- other annotation processors -->
                </annotationProcessorPaths>
            </configuration>
        </plugin>
Related