在学习注解处理器使用的时候,依据这个学习,完成后build,报了个错误:
Error:java: 服务配置文件不正确, 或构造处理程序对象javax.annotation.processing.Processor: Provider annotation.MyProcessor not found时抛出异常错误
我是使用maven的,不是使用教程的gralde,网上查找一番后,得到结果:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
<executions>
<execution>
<id>default-compile</id>
<configuration>
<compilerArgument>-proc:none</compilerArgument>
<includes>
<!-- 自定义的注解处理器全限定名-->
<include>per.annotation.MyProcessor</include>
</includes>
</configuration>
</execution>
<execution>
<id>compile-project</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
</executions>
</plugin>
成功了:
ps: 如果还有失败,maven clean下,把旧的target文件删除。