Announcement Announcement Module
No announcement yet.
Totally Confused on which Annotations to use Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Totally Confused on which Annotations to use

    so i'm new to spring, but done a lot of reading.. both the Spring in Action and Spring Docs, but maybe too much. I've decided to go the annotation route instead of the XML wiring, but there appears to be at least three different alternatives?? depending if you want to go JSR 250/330 (@inject/@named) or Spring(@Autowire/@Component) and now the Spring Java only with (@Config/@Bean).. the does anybody have a link to a good short/simple comparison? Especially for a newbie..

  • #2
    It depends on what you want... If you want component-scanning and autowiring use either @Inject/@Named or @Autowired/@Component.

    If you want to do the configuration yourself use @Configuration/@Bean... The latter is java-based configuration and must be seen as a replacement for XML...

    You can use either xml (component-scan) or @Configuration with @ComponentScan to enable component-scanning.


    • #3
      Autowiring always had impact on the performance impact in bean initialization if your context is has to many beans and dependencies.
      It is better to user @Configuration/@Bean to explicitly define the bean injections.