Announcement Announcement Module
Collapse
No announcement yet.
@Inject doesn't work Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • @Inject doesn't work

    Hello.
    In my application @Autowired works but @Inject doesn't.
    What could be the reasons for that?
    (@Inject is being recognised as a legal annotation. Dependencies were retrieved by maven).
    I use spring 3.0.0.RELEASE and javax.inject version 1 (in the pom.xml).

    Does it have anything to do with scope? Does JSR-330 have different scope than Spring?
    I would appreciate a simple and straight forward solution.
    Thanks in advance.
    Last edited by benma; Dec 20th, 2010, 02:48 AM.

  • #2
    Benma,

    I don't think the @Inject is a Spring type of annotation.

    I believe its a JEE type of annotation.

    If you want more info on Spring Annotation get this Refcard off Dzone.

    http://refcardz.dzone.com/refcardz/spring-annotations

    Please let me know if this helps.

    Comment


    • #3
      I don't think the @Inject is a Spring type of annotation.
      No, it's not; it's JSR-330 annotation interfaces. But Spring 3 passed the TCK so it IS a recognized implementation of those interfaces.

      For the original poster: did you properly annotate the beans you want injected using @Inject with the @Named annotation? Because if you use @Component, they won't be picked up by scanning for @Inject purposes.
      You either use @Autowired and @Component, OR @Inject and @Named.

      Comment


      • #4
        Thanks

        No, I used @Component and @Inject. Thanks for clarifying this for me.

        Comment

        Working...
        X