<?xml version= "1.0" encoding= "gb2312"?>
<!--the DTD definition for spring configuration file--
<! DOCTYPE beans Public "-//spring//dtd bean//en"
"Http://www.springframework.org/dtd/spring-beans.dtd" >
<!--the root element of the spring configuration file is beans-->
<beans>
<!--define the data source, the Bean's ID is datasource-->
<bean id= "DataSource" class= "Org.springframework.jdbc.datasource.DriverManagerDataSource" >
<!--specified database driver
<property name= "Driverclassname" ><value>com.mysql.jdbc.Driver</value></property>
<!--specify url--> to connect to the database
<property name= "url" ><value>jdbc:mysql://wonder:3306/j2ee</value></property>
<!--root is the user name of the database--
<property name= "username" ><value>root</value></property>
<!--Pass is a database password--
<property name= "Password" ><value>pass</value></property>
</bean>
<!--define Hibernate's sessionfactory-->
<bean id= "Sessionfactory" class= "Org.springframework.orm.hibernate3.LocalSessionFactoryBean" >
<!--relies on injected data sources to inject exactly the datasource--> defined above
<property name= "DataSource" ><ref local= "DataSource"/></property>
<!--The Mappingresouces property is used to list all mapping files >
<property name= "Mappingresources" >
<list>
<!--the following to list all PO mapping files--
<value>lee/Person.hbm.xml</value>
</list>
</property>
<!--defines the properties of Hibernate sessionfactory--
<property name= "Hibernateproperties" >
<props>
<!--specify Hibernate's connection dialect--
<prop key= "Hibernate.dialect" >org.hibernate.dialect.MySQLDialect</prop>
<!--different database connections, select create,update,create-drop--> at startup
<prop key= "Hibernate.hbm2ddl.auto" >update</prop>
</props>
</property>
</bean>
<!--Configure the DAO bean--> for the person persistence class
<bean id= "Persondao" class= "Lee. Persondaoimpl ">
<!--use dependency injection to pass in a reference to Sessionfactory
<property name= "sessionfactory" ><ref local= "Sessionfactory"/></property>
</bean>
</beans>
Applicationcontext.xml File Configuration Template