scala 缺少依赖项 'class javax.annotation.Nullable'

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13162671/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-22 04:41:16  来源:igfitidea点击:

Missing dependency 'class javax.annotation.Nullable'

javascalasbtjira-rest-java-api

提问by Jeffrey Cameron

I was trying to use the jira-rest-java-client provided by Atlassian in a Scala program I am developing. I am using Eclipse as my IDE.

我试图在我正在开发的 Scala 程序中使用 Atlassian 提供的 jira-rest-java-client。我使用 Eclipse 作为我的 IDE。

When I have an object of type Issue and I try to look at the properties I see there are far fewer properties than are declared in the Java code.

当我有一个 Issue 类型的对象并尝试查看属性时,我发现其中的属性远远少于 Java 代码中声明的属性。

I thought perhaps this was just Eclipse not finding all properties/methods of an object so I tried putting Issue.getSummary() and doing an sbt compile. The compile showed me this error:

我想这可能只是 Eclipse 没有找到对象的所有属性/方法,所以我尝试放置 Issue.getSummary() 并进行 sbt 编译。编译向我展示了这个错误:

Missing dependency 'class javax.annotation.Nullable'

缺少依赖项 'class javax.annotation.Nullable'

Any ideas?

有任何想法吗?

回答by Jeffrey Cameron

I found the answer in this issue on googlecode: http://code.google.com/p/guava-libraries/issues/detail?id=1095. To correct the problem in sbt you need to add this dependency:

我在 googlecode 上的这个问题中找到了答案:http: //code.google.com/p/guava-libraries/issues/detail? id= 1095。要纠正 sbt 中的问题,您需要添加此依赖项:

"com.google.code.findbugs" % "jsr305" % "1.3.+"

回答by Andrey E

The Scala compiler requires all annotation classes in the classpath. As this class is not available in the classpath, the compilation fails. In my particular case, the class is not used by the application. Hence, it is sufficient to disable the fatal-warningsoption in the build.

Scala 编译器需要类路径中的所有注释类。由于该类在类路径中不可用,编译失败。在我的特殊情况下,应用程序不使用该类。因此,fatal-warnings在构建中禁用该选项就足够 了。

In my built.sbtI had the following line:

在我的built.sbt我有以下几行:

scalacOptions ++= Seq("-Yno-adapted-args", "-Ywarn-dead-code", "-Ywarn-numeric-widen", "-Ywarn-value-discard", "-Xfatal-warnings")

I removed the "-Xfatal-warnings"and compilation was successful.

我删除了"-Xfatal-warnings",编译成功。