View Poll Results: Which Dependency Injection annotation do you favor?

Voters
132. You may not vote on this poll
  • @Inject

    30 22.73%
  • @Autowired

    85 64.39%
  • I don't use either.

    17 12.88%
Page 1 of 3 123 LastLast
Results 1 to 10 of 24

Thread: Which Dependency Injection annotation do you favor?

  1. #1
    Join Date
    Aug 2004
    Location
    Melbourne, FL
    Posts
    2,794

    Default Which Dependency Injection annotation do you favor?

    It's been awhile since we did one of these...

    Which dependency injection annotation do you favor?

    1. @Inject
    2. @Autowired
    3. I don't use either.

    Voting period closes in 2 weeks.
    Keith Donald
    Core Spring Development Team

  2. #2
    Join Date
    Nov 2009
    Location
    Montreal, Quebec
    Posts
    398

    Default

    @Inject does have the advantage of being a JSR, so it can be used without the Spring framework, although how widely is it used or known of? I first saw it used in a GemFire demo not long ago I believe, and then once again at S2GX. I have not used it myself (yet). I think for users new to the Spring framework and DI in general, they'll probably use @Autowired based on what they learn in the Spring documentation or tutorials. Would be great to see some kind of blog post comparing the equivalent use of both.

  3. #3
    Join Date
    Jul 2010
    Location
    Venice, Italy
    Posts
    709

    Default

    I voted for @Autowired, because I learned to use it and love it, and I wouldn't like to be forced to switch. Even if @Inject comes from a jsr specification (thus decoupling even more your application from the Spring framework) I don't see it as an issue (at least in the immediate future) since there really isn't, up to now, a good DI-based framework that can offer what Spring offers.

    Also, regarding jsr, since the Oracle acquisition my faith in the jcp has slowly begun to fade...but that is another matter...

  4. #4

    Thumbs up

    as rightly said by pgrimard, i recently started using annotation based DI and @Autowired is the first style that came naturally...
    i really liked easy of use and speed of development using @autowired.

  5. #5
    Join Date
    Dec 2010
    Location
    Singapore
    Posts
    285

    Default

    Have never used @Inject, so voted for @Autowired. But @Inject has an advantage of being a jsr. By the way very recently only i found this annotation.
    http://matthiaswessendorf.wordpress....e-jsr-330-way/

  6. #6

    Default

    i prefer @Inject i have used it for a long time and everything goes well about it using it can let you have less problems so i like it very much

  7. #7
    Join Date
    Jan 2011
    Posts
    1

    Default @Autowired

    I have a preference for @Autowired, because it's fast and easy, that's my opinion!


    Jeux de sport
    Last edited by lewisa; Jan 21st, 2011 at 07:46 AM.

  8. #8
    Join Date
    Jan 2011
    Location
    hyd
    Posts
    1

    Default

    I have prefered @autowired

  9. #9

    Default

    @Autowired ties your code to Spring. Using @Inject, you can run your code on Spring, Weld SE, Java EE 6, Guice, ...

    So don't use @Autowired if you want to be flexible.

    Regards,
    Harald

  10. #10

    Default Inject

    @Inject on new project.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •