I'm using Spring in a console Java application. My application will be deployed like:
folder/myJar.jar
folder/db/connection.properties
How do I load the connection.properties in a PropertyPlaceholderConfigurer
in application context?
I have tried
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="db/connection.properties"/>
</bean>
but it won't work.
I need it this way for my database username/password and other details.
Add the prefix file:
to the location value:
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="file:db/connection.properties"/>
</bean>
Specify that the file is on the classpath in the value attribute
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value="classpath:db/connection.properties"/>
</bean>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.