本文介绍了无法使用Lombok构建Maven Jhipster项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
./mvnw和mvn全新安装在添加lombok依赖项时失败,但从Intellij IDE启动时成功运行在下面找到错误:
./mvnw and mvn clean install fail when adding lombok dependency but run successfully when launched from Intellij IDEFind 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
这是POJO
import lombok.Builder;
import lombok.Data;
@Data
@Builder
public class Product {
private String name;
}
推荐答案
Jhipster生成的Maven项目在maven编译插件中使用了commentProcessorPaths,这就是为什么除非我们将lombok指定为注释处理器之一,否则它无法查找最新的lombok.
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.
工作代码如下.
<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>
这篇关于无法使用Lombok构建Maven Jhipster项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!