vendredi 6 mars 2015

Create bean in spring context


<bean id="configuration" class="com.mypackage.util.Configuration" factory-method="getInstance">
<property name="path" value="${path.props.app.dev}"></property>
</bean>


Then I have the following in my class



Configuration.getInstance();


Whereas the spring application context is loaded in another class Factory like this



private Factory() {
context = new ClassPathXmlApplicationContext("META-INF/spring.xml");
}


The problem is that before Factory class is accessed the context does not load and the configuration object gives null for path whereas when Factory is accessed and after that path property is accessed it gives the correct path.


Please tell me how to do it correctly? That is how can i get my member variable path with correct data without accessing Factory class.


Aucun commentaire:

Enregistrer un commentaire