Applicationcontext.xml file
<?xml version= "1.0" encoding= "UTF-8"?>
<beans xmlns= "Http://www.springframework.org/schema/beans"
xmlns:tx= "Http://www.springframework.org/schema/tx"
xmlns:aop= "HTTP://WWW.SPRINGFRAMEWORK.ORG/SCHEMA/AOP"
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-3.1.xsd
Http://www.springframework.org/schema/tx
Http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
Http://www.springframework.org/schema/aop
Http://www.springframework.org/schema/aop/spring-aop-3.1.xsd ">
<!--Configure Hibernate connection Information--
<bean id= "source" class= "Org.apache.commons.dbcp.BasicDataSource" >
<property name= "Driverclassname" value= "Oracle.jdbc.driver.OracleDriver"/>
<property name= "url" value= "Jdbc:oracle:thin: @localhost: 1521:orcl"/>
<property name= "username" value= "James"/>
<property name= "Password" value= "James"/>
</bean>
<!--configuration Sessionfactory--
<bean id= "Sessionfactory" class= "Org.springframework.orm.hibernate3.LocalSessionFactoryBean" >
<property name= "DataSource" ref= "source"/>
<!--Configure Hibernate other Parameters--
<property name= "Hibernateproperties" >
<props>
<prop key= "Hibernate.show_sql" >true</prop>
<prop key= "Hibernate.dialect" >org.hibernate.dialect.Oracle10gDialect</prop>
<prop key= "Javax.persistence.validation.mode" >none</prop>
</props>
</property>
<!--Configure Hibernate mapping file, non-annotated case--
<property name= "Mappingresources" >
<list>
<value>entity/Comments.hbm.xml</value>
<value>entity/News.hbm.xml</value>
<value>entity/User.hbm.xml</value>
<value>entity/Topic.hbm.xml</value>
</list>
</property>
</bean>
<!--configuring DAO injection Sessionfactory--
<bean id= "Userdao" class= "DAO. Userdaoimpl ">
<property name= "Sessionfactory" ref= "Sessionfactory"/>
</bean>
<!--inject Dao-to UserService
<bean id= "UserService" class= "service. Userserviceimpl ">
<property name= "Userdao" ref= "Userdao" ></property>
</bean>
<!--define transaction manager--
<bean id= "Txmanager" class= "Org.springframework.orm.hibernate3.HibernateTransactionManager" >
<property name= "Sessionfactory" ref= "Sessionfactory"/>
</bean>
<!--configuration Transaction Enhancements-
<tx:advice id= "Txadvice" transaction-manager= "Txmanager" >
<!--defining properties, declaring transaction rules--
<tx:attributes>
<tx:method name= "find*" read-only= "true"/>
<tx:method name= "search*" read-only= "true"/>
<tx:method name= "query*" read-only= "true"/>
<tx:method name= "add*" propagation= "REQUIRED"/>
<tx:method name= "del*" propagation= "REQUIRED"/>
<tx:method name= "update*" propagation= "REQUIRED"/>
<tx:method name= "do*" propagation= "REQUIRED"/>
<tx:method name= "*" propagation= "REQUIRED" read-only= "true"/>
</tx:attributes>
</tx:advice>
<aop:config>
<!--configuring Pointcuts--
<aop:pointcut expression= "Execution (* service.*.* (..))" id= "Servicemethod"/>
<!--to combine things before and from the point of entry--
<aop:advisor advice-ref= "Txadvice" pointcut-ref= "Servicemethod"/>
</aop:config>
</beans>
Web. xml file
<?xml version= "1.0" encoding= "UTF-8"?>
<web-app version= "3.0"
Xmlns= "Http://java.sun.com/xml/ns/javaee"
Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"
Xsi:schemalocation= "Http://java.sun.com/xml/ns/javaee
Http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd ">
<display-name></display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!--Opensessioninviewfilter, the configuration sub-function can be delayed load, that is, keep the session open with events-
<filter>
<filter-name>OpenSessionInViewFilter</filter-name>
<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>OpenSessionInViewFilter</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>
</web-app>
Spring integrates Hibernate's Applicationcontext.xml file configuration with Web. xml