This class help us to set the bean properties in a property file without even using placeholders in the xml file.
We can define bean the usual way:
<!-- The properties of the bean are missing in the xml as we will load them
from the properties file -->
<bean id="myDataSource"
class="org.springframework.jdbc.datasource.DriverManagerDataSource" />
Consider the property file:
#db2.properties
myDataSource.driverClassName=com.mysql.jdbc.Driver
myDataSource.url=jdbc:mysql://localhost:3306/test
myDataSource.username=root
myDataSource.password=
Now to refer to the location of properties file.
Old-style config:
<!-- Old style configuration-->
<bean class="org.springframework.beans.factory.config.PropertyOverrideConfigurer">
<property name="location" value="classpath:package-com.xxxx/db2.properties" />
</bean>
New style config : Use property-override
<!-- Using context schema to achieve the same -->
<context:property-override location="classpath:packageXXXX/db2.properties" />
No comments:
Post a Comment