Inject properties via a file with Spring
Par Nicolas, mardi 3 juin 2008 à 10:03 :: geek stuff :: #479 :: rss
Easy !
<bean id="SAPconnectionProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="location">
<value>classpath:sapconnection.properties</value>
</property>
</bean>
This configuration will create at runtime a Properties object and fill it with the properties contained in sapconnection.properties.
Then i just have to inject this bean in a containing bean, which has indeed a member such as described below :
private Properties SAPconnectionProperties;
And appropriate getter and setter of course...
Commentaires
Aucun commentaire pour le moment.
Ajouter un commentaire
Les commentaires pour ce billet sont fermés.