[英]The import javax.inject cannot be resolved while import Guava source
i would like to use the Guava's TypeToken , then i downloaded the Guava Release 14.0 from here . 我想使用Guava的TypeToken ,然后我从这里下载了Guava Release 14.0。 (i assume 14.0 is more stable than 15.0 rc.)
(我假设14.0比15.0 rc更稳定。)
guava-14.0.1-sources.jar (Source)
http://search.maven.org/remotecontent?filepath=com/google/guava/guava/14.0.1/guava-14.0.1-sources.jar
Unzip the downloaded guava-14.0.1-sources.jar
into a folder. 将下载的
guava-14.0.1-sources.jar
解压缩到一个文件夹中。
Then i created a Java 1.7 project in Eclipse. 然后我在Eclipse中创建了一个Java 1.7项目。
And linked the source in Eclipse by Java Build Path -> Source -> Link Source...
. 并通过
Java Build Path -> Source -> Link Source...
Eclipse中的Java Build Path -> Source -> Link Source...
。
Note i am not using (and don't know how to use) any build systems like Maven. 注意我没有使用(并且不知道如何使用)任何构建系统,如Maven。
First i got a problem of The import javax.annotation.Nullable cannot be resolved
. 首先我遇到了
The import javax.annotation.Nullable cannot be resolved
。 But this is solved already. 但这已经解决了。 i followed the thread here to download jsr305-2.0.1.jar from this page .
我按照这里的 主题从这个页面下载jsr305-2.0.1.jar 。 (i assume 2.0.1 is the most latest release.)
(我假设2.0.1是最新版本。)
Secondly i got the rt.jar access restriction
problem like this one . 其次我得到了像这样的
rt.jar access restriction
问题。 This is also solved by simply re-add the JRE System Library, like the answer there. 这也可以通过简单地重新添加JRE系统库来解决,就像那里的答案一样。
Now i got this problem that i cannot solve, and there are no solutions from the web. 现在我遇到了这个我无法解决的问题,并且没有来自网络的解决方案。
In package com.google.common.util.concurrent
class ServiceManager
, there are a few compile errors. 在
com.google.common.util.concurrent
类ServiceManager
,存在一些编译错误。
import javax.inject.Inject; // The import javax.inject cannot be resolved
import javax.inject.Singleton; // The import javax.inject cannot be resolved
To my understanding, this is a similar problem with the "first problem". 据我了解,这是“第一个问题”的类似问题。 But the
jsr305-2.0.1.jar
includes javax.annotation.Nullable
, but it does not include javax.inject.*
. 但是
jsr305-2.0.1.jar
包含javax.annotation.Nullable
,但它不包含javax.inject.*
。 What i need is a Java library that includes javax.inject.*
. 我需要的是一个包含
javax.inject.*
的Java库。
Could you please help? 能否请你帮忙? Thanks a lot!
非常感谢!
The javax.inject
package is provided in Java EE. Java EE中提供了
javax.inject
包。 If you're needing to use it in Java SE for some reason, you can explicitly include a jar with the API interface
s in it. 如果由于某种原因需要在Java SE中使用它,则可以显式包含一个带有API
interface
的jar。 Maven Central has a link to an implementation ( javax.inject:javax.inject
). Maven Central有一个指向实现的链接(
javax.inject:javax.inject
)。 Actually using Maven will make life simpler, but you can just download the jar
file and include it manually. 实际上使用Maven会让生活更简单,但你可以下载
jar
文件并手动包含它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.