我已经实现了 this question 的答案使 @Nonnull 违规使构建失败。但问题是,这会发现很多我不想处理的其他错误。我看过 the manual ,并且没有任何部分像“这是您配置要检查的内容”一章那样突然出现在我面前。
对我来说好像是it should be in here ,但选项的数量似乎还不够全面。我如何将 findbugs 配置为仅关心 findbugs 注释?
我可能会接受告诉我如何在不使用 maven 插件的情况下执行此操作的答案,因为我认为我可以弄清楚如何将其转换为插件可以使用的内容。
最佳答案
这是我使用的 findbugs maven 配置:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>2.4.0</version>
<configuration>
<excludeFilterFile>findbugs-exclude.xml</excludeFilterFile>
<findbugsXmlOutput>true</findbugsXmlOutput>
<xmlOutput>true</xmlOutput>
</configuration>
</plugin>
findbugs-exclude.xml 文件位于我的项目根目录中(与 pom.xml 处于同一级别 - 我可能应该将其放在更好的地方),它配置了我想忽略的 findbugs 问题。这是我的排除文件中的内容:
<?xml version="1.0" encoding="UTF-8"?>
<FindBugsFilter>
<Match>
<Bug pattern="EI_EXPOSE_REP,EI_EXPOSE_REP2"/>
</Match>
<Match>
<Package name="com.mypackage.something"/>
</Match>
</FindBugsFilter>
有关配置 findbugs 过滤器文件的更多信息 in the findbugs manual
另外请注意,您可以更改 findbugs maven 插件以仅包含某些使用此过滤器而不是 excludeFilterFile
的过滤器:
<includeFilterFile>findbugs-include.xml</includeFilterFile>
关于java - 如何将 FindBugs maven 插件配置为仅检查 @Nonnull 等注释违规?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23550195/