Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't build maven jhipster project with lombok

./mvnw and mvn clean install fail when adding lombok dependency but run successfully when launched from Intellij IDE Find the error below :

INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] src/main/java/web/rest/core/service/impl/ProductServiceImpl.java:[18,29] cannot find symbol
  symbol:   method builder()
  location: class com.test.one.web.rest.core.model.Product

Here is the POJO

import lombok.Builder;
import lombok.Data;

@Data
@Builder
public class Product {
    private String name;
}
like image 372
freemanpolys Avatar asked Jun 17 '17 08:06

freemanpolys


1 Answers

The maven project Jhipster generated uses a annotationProcessorPaths in the maven compile plugin, that's why it cannot look up the latest lombok unless we specify lombok as one of the annotation processor.

Working code is as followed.

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
    <annotationProcessorPaths>
        <path>
            <groupId>org.mapstruct</groupId>
            <artifactId>mapstruct-processor</artifactId>
            <version>${mapstruct.version}</version>
        </path>
        <!-- For JPA static metamodel generation -->
        <path>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-jpamodelgen</artifactId>
            <version>${hibernate.version}</version>
        </path>
        <path>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <version>1.16.18</version>
        </path>
    </annotationProcessorPaths>
</configuration>

like image 70
Jimmy Wong Avatar answered Nov 18 '22 10:11

Jimmy Wong