This forum is now a read-only archive. All commenting, posting, registration services have been turned off. Those needing community support and/or wanting to ask questions should refer to the Tag/Forum map, and to http://spring.io/questions for a curated list of stackoverflow tags that Pivotal engineers, and the community, monitor.

AnnouncementAnnouncement Module

Collapse

No announcement yet.

Is it possible to read the bean definitions without initializing the context?Page Title Module

Is it possible to read the bean definitions without initializing the context?

Aug 24th, 2012, 03:23 PM

Hi everyone,

I need to read the bean definitions of a set of Spring configuration files without instantiating the beans.
The purpose of this is to go through the bean definitions and detect which beans contain properties whose values came from a placeholder.

My initial attempt was this, which loads the context in the first line:

However, I can't initialize the context since there are beans that have a constructor argument that require having a valid value upon instantiation, and the placeholder's format makes that validation fail.

But that code causes this exception:java.lang.IllegalStateException: BeanFactory not initialized or already closed - call 'refresh' before accessing beans via the ApplicationContext
at org.springframework.context.support.AbstractRefres hableApplicationContext.getBeanFactory(AbstractRef reshableApplicationContext.java:171)

Is there a way to read the context configuration without the initialization of the context?