Announcement Announcement Module
Collapse
No announcement yet.
how to inject the the application context into object Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • how to inject the the application context into object

    Hi,

    How do I inject the application context into an object?


    <bean name="obj" class="MyObj">
    <property name="context" ref="this???"/>
    </bean>


    -Tim125

  • #2
    Make your class implement the interface ApplicationContextAware, which will mean you have to add a setApplicationContext method. Then, as if by magic, Spring will detect that you have implemented this interface and will inject the context automatically at startup. You don't need to define a bean property at all.

    Comment

    Working...
    X