创建子工程发现lombok注解不生效了 然后各种重装 最后发现是IDEA的注解处理器 自己选择了一个类路径 正常应该是从项目类路径获取注释处理器 但是这个子工程却是自动选择了一个路径来获取注释处理器 重新创建子工程也是一样
6 Likes
有没有什么办法让它默认就是自动获取项目类路径注释处理器
看起来像是某次设置之后被 IDEA 记到项目配置了?
这个设置只对新项目有效,你当前项目修改了吗?
看一下你的这个配置文件内容 .idea/compiler.xml
1 Like
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<profile default="true" name="Default" enabled="true" />
<profile name="Maven default annotation processors profile" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<module name="Spring02" />
<module name="spring03" />
<module name="SpringMVC" />
</profile>
<profile name="Annotation profile for springparent" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<processorPath>
<entry name="$PROJECT_DIR$/../../../repository/org/projectlombok/lombok/unknown/lombok-unknown.jar" />
</processorPath>
<module name="springmvc2" />
</profile>
<profile name="Annotation profile for mybatis01" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<processorPath>
<entry name="$PROJECT_DIR$/../../../repository/org/projectlombok/lombok/unknown/lombok-unknown.jar" />
</processorPath>
<module name="mybatis01" />
</profile>
<profile name="Annotation profile for mybatis02" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<processorPath useClasspath="false">
<entry name="$PROJECT_DIR$/../../../repository/org/projectlombok/lombok/unknown/lombok-unknown.jar" />
<entry name="$PROJECT_DIR$/../../../repository/org/projectlombok/lombok/unknown/lombok-unknown.jar" />
</processorPath>
<module name="mybatis02" />
</profile>
</annotationProcessing>
<bytecodeTargetLevel>
<module name="spring01" target="17" />
<module name="Spring03" target="17" />
<module name="SpringMVC02" target="17" />
<module name="SprinMVC" target="17" />
</bytecodeTargetLevel>
</component>
<component name="JavacSettings">
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
<module name="SprinMVC" options="-parameters" />
<module name="Spring02" options="-parameters" />
<module name="Spring03" options="-parameters" />
<module name="SpringMVC" options="-parameters" />
<module name="SpringMVC02" options="-parameters" />
<module name="mybatis01" options="-parameters" />
<module name="mybatis02" options="-parameters" />
<module name="spring01" options="-parameters" />
<module name="spring03" options="-parameters" />
<module name="springmvc2" options="-parameters" />
<module name="springparent" options="" />
</option>
</component>
</project>
这里佬
1 Like
是processorPath useClasspath标签的问题吗?
1 Like
如果你前面正确设置了新项目默认配置,新project应该不会再出现问题了。
你看看蓝色箭头的这个 Default 是不是也有问题
新建子工程理论上是继承Default或Maven Default的
这个问题我也没遇到过哈,佬研究一下
感谢回复
我确实正确设置了新项目的默认配置 但是创建父工程没问题 但是一旦在父工程内创建子工程又依然出现这个问题了
而且发现每次刷新maven后就会自动变回下面那个自定义处理器 把文件删掉依然会重新下回来- -
您有空可以研究研究 出问题我就手动get set 了 不算太耽搁
是不是用idea新生成的Spring项目?新生成的项目配置有问题,需要将所有 pom.xml 中的:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
改为
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
</plugin>
</plugins>
</build>
即删除掉
<configuration>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
</path>
</annotationProcessorPaths>
</configuration>
可解。我也被坑了几星期,刚试出来解决方案。
3 Likes
嗯嗯对的 是这样的 我把pom重新手敲一边就ok了