1.在WEB.XML中必须有以下内容
2.在SRC的目录下应该有ApplicationContext-common.xml(让其自动生成SessionFactory进行生成表的管理?)
- <context-param>
- <param-name>contextConfigLocation</param-name>
- <param-value>/WEB-INF/applicationContext-*.xml,classpath*:applicationContext-*.xml</param-value>
- </context-param>
- <listener>
- <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
- </listener>
- <?xmlversion="1.0"encoding="UTF-8"?>
- <beansxmlns="http://www.springframework.org/schema/beans"
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:aop="http://www.springframework.org/schema/aop"
- xmlns:tx="http://www.springframework.org/schema/tx"
- xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-2.0.xsd
- http://www.springframework.org/schema/aophttp://www.springframework.org/schema/aop/spring-aop-2.0.xsd
- http://www.springframework.org/schema/txhttp://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
- <!--配置sessionFactory-->
- <beanid="sessionFactory"class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
- <propertyname="configLocation">
- <value>classpath:hibernate.cfg.xml</value>
- </property>
- </bean>
- <!--配置事务管理器-->
- <beanid="transactionManager"class="org.springframework.orm.hibernate3.HibernateTransactionManager">
- <propertyname="sessionFactory">
- <reflocal="sessionFactory"/>
- </property>
- </bean>
- <!--配置事务特性-->
- <tx:adviceid="txAdvice"transaction-manager="transactionManager">
- <tx:attributes>
- <tx:methodname="add*"propagation="REQUIRED"/>
- <tx:methodname="del*"propagation="REQUIRED"/>
- <tx:methodname="update*"propagation="REQUIRED"/>
- <tx:methodname="*"read-only="true"/>
- </tx:attributes>
- </tx:advice>
- <!--配置那些类的方法进行事务管理-->
- <aop:config>
- <aop:pointcutid="allManagerMethod"expression="execution(*com.bjsxt.oa.manager.*.*(..))"/>
- <aop:advisoradvice-ref="txAdvice"pointcut-ref="allManagerMethod"/>
- </aop:config>
- </beans>