./ mvnw和mvn clean install失败,但从Intellij IDE启动时运行成功 找到以下错误:
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;
}
答案 0 :(得分:7)
生成的maven项目Jhipster在maven编译插件中使用了annotationProcessorPaths,这就是为什么它不能查找最新的lombok,除非我们将lombok指定为注释处理器之一。
工作代码如下。
<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>
答案 1 :(得分:1)
我设法使用以下版本组合:
例如,pom.xml:
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.16.18</version>
<scope>provided</scope>
</dependency>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
</plugin>