Announcement Announcement Module
Collapse
No announcement yet.
Spring Annotation Cheat Sheet Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Spring Annotation Cheat Sheet

    Thought this could be helpful for newbies like me..


    <context:component-scan base-package="packageName"/> -- looks out for @Controllers, @Component

    <context:annotation-config/> -- enables @Autowire

    <context:include-filter type="annotation" -- filters type of annotation to look out for

    @Autowired
    -- regular injection.., member variables

    @Component
    -- Class level

    @Controller
    -- Servlet

    @InitBinder
    -- form binder/Custom Property Editor

    @ManagedAttribute
    -- helps in exposing through JMX

    @ManagedOperation
    -- helps in exposing through JMX

    @ManagedOperationParameters
    -- helps in exposing through JMX

    @ManagedOperationParameter
    -- helps in exposing through JMX

    @ManagedResource
    -- helps in exposing through JMX

    @PathVariable
    -- part of rest based request..dynamic value

    @PostConstruct
    -- J2EE annotation to be used for init callback method.


    @PreDestroy
    -- J2EE annotation to be used for destroy callback method.

    @RequestMapping
    -- methods in controller..relative url


    @Required
    -- Marks a method (typically a JavaBean setter method) as being 'required':

    @Resource
    -- ??

    @Service
    -- @Service is a specialisation of @Component to indicate a component in your service layer.

    @Transactional



    @Component -- Parent generic annotation

    - @Service is a specialisation of @Component to indicate a component in your service layer.
    - @Repository to indicate a DAO
    - @Controller in the presentation layer



    @Qualifier
    Since autowiring by type may lead to multiple candidates, it is often necessary to have more control over the selection process. One way to accomplish this is with Spring's @Qualifier annotation.
Working...
X