使用findbugs的Java编译错误. com.sun.tools.javac.code.Symbol $ CompletionFailure:javax.annotation.meta的类文件 [英] java compilation error using findbugs. com.sun.tools.javac.code.Symbol$CompletionFailure: class file for javax.annotation.meta.When not found

查看:340
本文介绍了使用findbugs的Java编译错误. com.sun.tools.javac.code.Symbol $ CompletionFailure:javax.annotation.meta的类文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用findbugs 1.3.2的注释.

I am trying to use the annotations of findbugs 1.3.2.

我在一个简单的测试中使用了edu.umd.cs.findbugs.annotations.NonNull注释, 而且效果很好.

I used the edu.umd.cs.findbugs.annotations.NonNull annotation in a simple test, and it works fine.

但是,现在我有一个大型项目,由子模块组成,使用maven, 并且通过仅在某些Java文件中导入该批注而得到以下编译错误:

However, now I have a large project, composed of sub-modules, using maven, and I get the following compilation error by just importing that annotation in some java file:

com.sun.tools.javac.code.Symbol$CompletionFailure: class file for javax.annotation.meta.When not found

可能是什么问题? 我尝试在所有子模块中添加findbugs依赖项. 也许是与jsr305冲突?我看到我们的依赖项之一使用了jsr305 1.3.9.

what can be the problem? i tried adding the findbugs dependency in all sub-modules. maybe it is a conflict with jsr305? I see that one of our dependencies uses jsr305 1.3.9.

推荐答案

以我的经验,当您使用@NunNull且jsr305.jar不在类路径上时,总是会发生此错误.为了使用findbugs批注,您必须将批注.jar和jsr305.jar都添加到类路径中.
某些注释(我认为是@SuppressWarnings)可以在没有jsr305.jar的情况下使用,但是@NonNull肯定需要它.

In my experience, this error always occurs when you use @NunNull and jsr305.jar is not on the classpath. In order to use the findbugs annotations, you must add both annotations.jar and jsr305.jar to the classpath.
Some annotations (I am thinking of @SuppressWarnings) can be used without jsr305.jar, but @NonNull requires it for sure.

(您在问题中提到jsr305.jar,但没有明确说您已经检查过.此外,人们在搜索错误消息时将落在这里,因此他们需要添加jsr305.jar .)类路径上只能有一个jsr305.jar版本.

(You mentioned jsr305.jar in your question, but you didn't say explicitly that you've checked. Also, people are going to land here when searching for the error message, and they will need to add jsr305.jar.) Only one version of jsr305.jar should be on the classpath.

这篇关于使用findbugs的Java编译错误. com.sun.tools.javac.code.Symbol $ CompletionFailure:javax.annotation.meta的类文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆