1.起因
使用Idea2020.3版本创建多模块项目后在springboot-test下测试 编译以下代码报错
@Test
void contextLoads() {
Product build = Product.builder().name("111").id(1L).sku("411").build();
}
错误信息
java: JPS incremental annotation processing is disabled. Compilation results on partial recompilation may be inaccurate. Use build process "jps.track.ap.dependencies" VM flag to enable/disable incremental annotation processing environment.
实体类
百度查找,stackoverflow,github多番搜索得到三种方案尝试均无效,链接:
https://stackoverflow.com/questions/66170975/jps-incremental-annotation-processing-is-disabled-compilation-results-on-partia
https://github.com/projectlombok/lombok/issues/2592
有同样问题的可以尝试,以上方案对我都无效
最后发现
.idea文件夹下该idea配置文件中缺少lombok依赖导致,添加后可以正常编译
确定是compiler.xml问题后修改如下配置
可以看到,default下的processor path 为空
复制子模块processor path到default即可
编译正常
但是此方式并不合适
在pom.xml中添加以下配置可以正确加载
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.20</version>
</path>
<!-- other annotation processors -->
</annotationProcessorPaths>
</configuration>
</plugin>
jdk8 以上版本如果使用module-info.java 需要添加此配置
结束