除了用xml的形式去忽略一些文件和bug。最好用的还是注解:
下面的方法会有MT_CORRECTNESS和STYLE的bug。注解忽略方法为:
@edu.umd.cs.findbugs.annotations.SuppressFBWarnings(
value = {"MT_CORRECTNESS", "STYLE"},
justification = "I know what I'm doing")
public JdbcTemplate get(String datasourceName) {
JdbcTemplate jdbcTemplate = TEMPLATE.get(datasourceName);
if (jdbcTemplate == null) {
synchronized (this) {
if (jdbcTemplate == null) {
jdbcTemplate = createTemplate(datasourceName);
TEMPLATE.put(datasourceName, jdbcTemplate);
}
return jdbcTemplate;
}
}
return jdbcTemplate;
}
需要添加以下依赖
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>annotations</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有