无法从 Maven 项目中删除 java 注释处理器
Cannot remove java annotation processor from maven project
我即将重构我的脏注解处理器。因此我想创建一个新的来从旧的中提取一些责任。
旧: com.company.coma.shared.annotation.ComaToolAnnotationProcessor
新: com.company.coma.shared.annotation.ToolProcessor
现在我已经从 pom.xml
的配置中删除了旧的
pom.xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<generatedSourcesDirectory>
${project.build.directory}/generated-sources/
</generatedSourcesDirectory>
<annotationProcessors>
<annotationProcessor>
com.company.coma.shared.annotation.ToolProcessor
</annotationProcessor>
<!--<annotationProcessor>-->
<!--com.company.coma.shared.annotation.ComaToolAnnotationProcessor-->
<!--</annotationProcessor>-->
</annotationProcessors>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
我还完全删除 ComaToolAnnotationProcessor.java 文件,然后重建整个项目。
这仍然是我的 clean install
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.5.1:compile (default-compile) on project module-foo: Compilation failure
[ERROR] Annotation processor 'com.company.coma.shared.annotation.ComaToolAnnotationProcessor' not found
这是怎么回事?即使我从整个项目中删除了它的任何命名,它怎么还能找到它?
EDIT#1:停用整个注释处理插件(maven-compiler)也无济于事。我不明白这是怎么回事。看来我对依赖项或配置没有影响了。
可能您已经(手动或未手动)将处理器添加到您的 META-INF/services
文件中。因此它将尝试 运行 它,并在找不到指定的 class 时失败。我相信删除引用可能会解决问题:)
我发现了问题。我最近重命名了我的 parent 模块之一。但是实际包含要处理的文件的子模块仍然引用旧的 parent 工件。这样一来,我认为新 parent 的所有配置都不会影响任何东西。很奇怪,因为旧的 parent 模块从我的项目结构中完全消失了,但它肯定仍然在我的 Maven 存储库中可用。
我非常依赖 IDE 的 module-name 重构功能。
我即将重构我的脏注解处理器。因此我想创建一个新的来从旧的中提取一些责任。
旧: com.company.coma.shared.annotation.ComaToolAnnotationProcessor
新: com.company.coma.shared.annotation.ToolProcessor
现在我已经从 pom.xml
的配置中删除了旧的pom.xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<generatedSourcesDirectory>
${project.build.directory}/generated-sources/
</generatedSourcesDirectory>
<annotationProcessors>
<annotationProcessor>
com.company.coma.shared.annotation.ToolProcessor
</annotationProcessor>
<!--<annotationProcessor>-->
<!--com.company.coma.shared.annotation.ComaToolAnnotationProcessor-->
<!--</annotationProcessor>-->
</annotationProcessors>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
我还完全删除 ComaToolAnnotationProcessor.java 文件,然后重建整个项目。
这仍然是我的 clean install
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.5.1:compile (default-compile) on project module-foo: Compilation failure
[ERROR] Annotation processor 'com.company.coma.shared.annotation.ComaToolAnnotationProcessor' not found
这是怎么回事?即使我从整个项目中删除了它的任何命名,它怎么还能找到它?
EDIT#1:停用整个注释处理插件(maven-compiler)也无济于事。我不明白这是怎么回事。看来我对依赖项或配置没有影响了。
可能您已经(手动或未手动)将处理器添加到您的 META-INF/services
文件中。因此它将尝试 运行 它,并在找不到指定的 class 时失败。我相信删除引用可能会解决问题:)
我发现了问题。我最近重命名了我的 parent 模块之一。但是实际包含要处理的文件的子模块仍然引用旧的 parent 工件。这样一来,我认为新 parent 的所有配置都不会影响任何东西。很奇怪,因为旧的 parent 模块从我的项目结构中完全消失了,但它肯定仍然在我的 Maven 存储库中可用。
我非常依赖 IDE 的 module-name 重构功能。