how to set property in .properties file before spring come into picture? -
i have password coming command line argument before initializing/instantiating bean in ioc container want set password 1 key in .properties file. spring same property .properties file instantiate datasource object. how can that? please help.
project.properties
# db info jdbc.driver=org.hsqldb.jdbcdriver jdbc.url=jdbc:hsqldb:db/myapp jdbc.user=sa jdbc.password= jdbc.maxconnections=25
spring beans.xml
<bean id="propertyconfigurer" class="org.springframework.beans.factory.config.propertyplaceholderconfigurer"> <property name="location"> <value>classpath:project.properties</value> </property> </bean> <bean id="datasource" class="org.springframework.jdbc.datasource.drivermanagerdatasource"> <property name="driverclassname"><value>${jdbc.driver}</value></property> <property name="url"><value>${jdbc.url}</value></property> <property name="username"><value>${jdbc.user}</value></property> <property name="password"><value>${jdbc.password}</value></property> </bean>
Comments
Post a Comment