我有一个
public interface Interface0 {
void method0();
}
和一个
public class Implementation0 implements Interface0 {
public void method0() {
throw new UnsupportedOperationException("Not supported yet.");
}
}
我maven-checkstyle-plugin
通过声明使用
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>checkstyle</id>
<phase>validate</phase>
<goals>
<goal>check</goal>
</goals>
</execution>
</executions>
<configuration>
<configLocation>${basedir}/check_style.xml</configLocation>
</configuration>
</plugin>
最后我正在MissingOverride
激活check_style.xml
:
<?xml version="1.0"?>
<!DOCTYPE module PUBLIC
"-//Puppy Crawl//DTD Check Configuration 1.2//EN"
"http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
<module name="Checker">
<module name="TreeWalker">
<module name="MissingOverride"/>
</module>
</module>
这是我在许多项目中的经验摘录,所有检查都可以正常工作,除了MissingOverride
没有效果,即没有检测到单个缺失的@Override
注释。