How the Spring Framework's XML file reads the properties file data
First step: In the Spring configuration file
Note: Value can be configured with more than a few properties files
<bean id= "Propertyconfigurer"
class= "Org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" >
<property name= "Locations" >
<list>
<value>/db.properties</value>
</list>
</property>
</bean>
Step Two:
Build the Db.properties file under the src directory
User=sa
Password=sa
Driver=com.microsoft.sqlserver.jdbc.sqlserverdriver
Url=jdbc:sqlserver://localhost:1433;databasename=db1
Step Three:
called in Spring's configuration file by means of an El expression
${user}
<?xml version= "1.0" encoding= "UTF-8"?>
<beans xmlns= "Http://www.springframework.org/schema/beans"
xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"
xsi:schemalocation= "Http://www.springframework.org/schema/beans Http://www.springframework.org/schema/beans /spring-beans-2.0.xsd ">
<bean id= "Propertyconfigurer"
class= "Org.springframework.beans.factory.config.PropertyPlaceholderConfigurer" >
<property name= "Locations" >
<list>
<value>/db.properties</value>
</list>
</property>
</bean>
<bean id= "DataSource"
class= "Org.springframework.jdbc.datasource.DriverManagerDataSource" >
<property name= "Driverclassname"
value= "${driver}" >
</property>
<property name= "url"
value= "${url}" >
</property>
<property name= "username" value= "${user}" ></property>
<property name= "password" value= "${password}" ></property>
</bean>
<bean id= "Sessionfactory"
class= "Org.springframework.orm.hibernate3.LocalSessionFactoryBean" >
<property name= "DataSource" >
<ref bean= "datasource"/>
</property>
<property name= "hibernateproperties" >
<props>
<prop key= "Hibernate.dialect" >
org.hibernate.dialect.SQLServerDialect
</prop>
</props>
</property>
<property name= "mappingresources" >
<list>
<value>entity/Users.hbm.xml</value>
</list>
</property>
</bean>
<bean id= "Usersdao" class= "DAO. Usersdao ">
<property name= "Sessionfactory" >
<ref bean= "sessionfactory"/>
</property>
</bean>
</beans>
How the Spring Framework's XML file reads the properties file data