Java 我在哪里可以找到@Inject jar

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4131190/
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-08-14 11:55:48  来源:igfitidea点击:

Where I can find @Inject jar

javaspringannotations

提问by Adi Sembiring

I'm following the MVC unit test instructions from this site, but I cannot find the jar for the @Injectannotation. Does anybody know where the jar is?

我正在按照此站点的 MVC 单元测试说明进行操作,但找不到@Inject注释的 jar 。有人知道罐子在哪里吗?

采纳答案by Sean Patrick Floyd

Via Maven:

通过 Maven:

<dependency>
  <groupId>javax.inject</groupId>
  <artifactId>javax.inject</artifactId>
  <version>1</version>
</dependency>

Or from the Project Home Page: http://code.google.com/p/atinject/

或从项目主页:http: //code.google.com/p/atinject/

Also, this MvnRepository.com pageprovides the necessary configurations for other build tools like Ivy, Gradle etc.

此外,这个 MvnRepository.com 页面为 Ivy、Gradle 等其他构建工具提供了必要的配置。

回答by Darko Vasilev

You can use Sun's official:

你可以使用Sun的官方:

<dependency>
    <groupId>javax</groupId>
    <artifactId>javaee-api</artifactId>
    <version>6.0</version>
</dependency>

Cheers!

干杯!

回答by SaW

Using javaee-apiinstead of javax.injectI ran into a bunch of issues.

使用javaee-api而不是javax.inject我遇到了一堆问题。

After some digging I found out that you need to add it with scope provided or otherwise it will add a Listener (com.sun.faces.config.ConfigureListener) at runtime.

经过一番挖掘,我发现您需要使用提供的范围添加它,否则它将com.sun.faces.config.ConfigureListener在运行时添加一个 Listener ( ) 。

Another issue is that apparently the implementation to inject is different. Fields annotated with @injectremained null. By replacing the official sun jar with the javax.inject, this no longer happened.

另一个问题是,注入的实现显然不同。注释为@inject空的字段。通过用 替换官方太阳罐javax.inject,这不再发生。

Note that i'm not an expert, I might be running into side-effects, but figuring this out took me such a long time, that I felt I had to share my findings so far.

请注意,我不是专家,我可能会遇到副作用,但弄清楚这一点花了我很长时间,以至于我觉得我必须分享到目前为止的发现。