我找到了解决此问题的解决方法。似乎基于注释的注入的检测在FindBugs中是硬编码的,请参阅以下源代码:
public static boolean isInjectionAttribute(@DottedClassName String annotationClass) {
if (annotationClass.startsWith("javax.annotation.")
|| annotationClass.startsWith("javax.ejb")
|| annotationClass.equals("org.apache.tapestry5.annotations.Persist")
|| annotationClass.equals("org.jboss.seam.annotations.In")
|| annotationClass.startsWith("javax.persistence")
|| annotationClass.endsWith("SpringBean")
|| annotationClass.equals("com.google.inject.Inject")
|| annotationClass.startsWith("com.google.") && annotationClass.endsWith(".Bind")
&& annotationClass.hashCode() == -243168318
|| annotationClass.startsWith("org.nuxeo.common.xmap.annotation")
|| annotationClass.startsWith("com.google.gwt.uibinder.client")
|| annotationClass.startsWith("org.springframework.beans.factory.annotation")
|| annotationClass.equals("javax.ws.rs.core.Context")) {
return true;
}
int lastDot = annotationClass.lastIndexOf('.');
String lastPart = annotationClass.substring(lastDot + 1);
if (lastPart.startsWith("Inject")) {
return true;
}
return false;
}
因此,像这样的注释不会显示为UR错误,但我的注释将始终是UR错误。@EJB
@CustomInjection
但是在函数的末尾,所有以“Inject”开头的注释名都有一个转义,所以如果我重命名为UR,bug就会消失。因此,要避免此问题,只需将注释重命名为 .@CustomInjection
@InjectCustom
@InjectSomething