Where I can find @Inject jar

前端 未结 3 1656
情话喂你
情话喂你 2020-12-17 07:47

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

相关标签:
3条回答
  • 2020-12-17 08:03

    Via 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/

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

    0 讨论(0)
  • 2020-12-17 08:20

    You can use Sun's official:

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

    Cheers!

    0 讨论(0)
  • 2020-12-17 08:28

    Using javaee-api instead of javax.inject I ran into a bunch of issues.

    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.

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

    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.

    0 讨论(0)
提交回复
热议问题