简体   繁体   English

我在哪里可以找到@Inject jar

[英]Where I can find @Inject jar

I'm following the MVC unit test instructions from this site , but I cannot find the jar for the @Inject annotation. 我正在关注这个站点的MVC单元测试指令,但我找不到@Inject注释的jar。 Does anybody know where the jar is? 有人知道罐子在哪里吗?

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 page provides the necessary configurations for other build tools like Ivy, Gradle etc. 此外, 此MvnRepository.com页面还为其他构建工具(如Ivy,Gradle等)提供了必要的配置。

Using javaee-api instead of javax.inject I 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. 经过一番挖掘后,我发现你需要在提供的范围内添加它,否则它会在运行时添加一个Listener( com.sun.faces.config.ConfigureListener )。

Another issue is that apparently the implementation to inject is different. 另一个问题是,注入的实现显然是不同的。 Fields annotated with @inject remained null. @inject注释的字段保持为空。 By replacing the official sun jar with the javax.inject , this no longer happened. 通过用javax.inject替换官方sun jar,这不再发生。

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. 请注意,我不是专家,我可能会遇到副作用,但解决这个问题花了我很长时间,我觉得我必须分享我的发现到目前为止。

You can use Sun's official: 你可以使用Sun的官方:

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

Cheers! 干杯!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM