Announcement Announcement Module
Collapse
No announcement yet.
Bean initialization not happening Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Bean initialization not happening

    I'm trying to write a standalone Spring app, and I just can't get the afterPropertiesSet methods of IntitializingBean beans to get executed. This is what my main app does:

    Resource resource = new FileSystemResource("config/spring-config.xml");
    XmlBeanFactory bf = new XmlBeanFactory(resource);

    won't this by default also initialize beans that implement the required interface? Is there anything else I need to do for that to happen?

    Thanks.

  • #2
    If you would use an ApplicationContext initialization would happen automatically. For BeanFactory classes you need to invoke the "preInstantiateSingletons" method.

    Generally using an ApplicationContext is recommended for most cases.

    Comment


    • #3
      Just to confirm Andreas's advice check out the reference manual, it does cover this.
      http://www.springframework.org/docs/...nce/beans.html
      Last edited by karldmoore; Aug 27th, 2007, 04:13 PM.

      Comment

      Working...
      X