81,094
社区成员
发帖
与我相关
我的任务
分享
<?xml version="1.0" encoding="UTF-8"?>
<beans
xmlns="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/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd
">
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="configLocation"
value="classpath:hibernate.cfg.xml">
</property>
</bean>
<!-- 配置事务管理器 -->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="sessionFactory"/>
</property>
</bean>
<!-- 配置事务的传播特性 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager" >
<tx:attributes>
<!-- 在开发的时候可以这样定义,但部署的时候一定要详细定义 -->
<tx:method name="*" propagation="REQUIRED"/>
<!--
<tx:method name="add*" propagation="REQUIRED"/>
<tx:method name="del*" propagation="REQUIRED"/>
<tx:method name="update*" propagation="REQUIRED"/>
<tx:method name="*" read-only="true"/>
-->
</tx:attributes>
</tx:advice>
<!-- 配置哪些类哪些方法使用事务 -->
<aop:config>
<aop:pointcut id="txAdvicePointcut" expression="execution(* com.nuist.service.*.*(..))"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="txAdvicePointcut"/>
</aop:config>
</beans>
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" 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_2_5.xsd">
<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>
<filter>
<filter-name>struts2</filter-name>
<filter-class>org.apache.struts2.dispatcher.FilterDispatcher</filter-class>
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
<?xml version="1.0" encoding="UTF-8" ?>
- <beans xmlns="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" xmlns:p="http://www.springframework.org/schema/p" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd">
- <!-- session工厂
-->
- <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation" value="classpath:hibernate.cfg.xml" />
</bean>
- <!-- session模板
-->
- <bean id="ht" class="org.springframework.orm.hibernate3.HibernateTemplate">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
- <!-- Dao 数据库访问通用类
-->
- <bean id="basicDao" class="tjy.hrm.common.BasicHibernateDaoImpl">
<property name="hibernateTemplate" ref="ht" />
</bean>
- <bean id="parentDao" abstract="true">
<property name="common" ref="basicDao" />
</bean>
<bean id="userDao" class="tjy.hrm.dao.UserDaoImpl" parent="parentDao" />
<bean id="funcDao" class="tjy.hrm.dao.FuncDaoImpl" parent="parentDao" />
<bean id="posDao" class="tjy.hrm.dao.PosDaoImpl" parent="parentDao" />
<bean id="funcTypeDao" class="tjy.hrm.dao.FuncTypeDaoImpl" parent="parentDao" />
<bean id="deptDao" class="tjy.hrm.dao.DeptDaoImpl" parent="parentDao" />
- <!-- Biz 权限模块业务类
-->
- <bean id="popedomBiz" class="tjy.hrm.biz.PopedomBizImpl">
<property name="deptDao" ref="deptDao" />
<property name="userDao" ref="userDao" />
<property name="posDao" ref="posDao" />
<property name="funcTypeDao" ref="funcTypeDao" />
<property name="funcDao" ref="funcDao" />
</bean>
- <!-- Action
-->
- <bean name="/popedom" class="tjy.hrm.actions.PopedomAction">
<property name="popedomBiz" ref="popedomBiz" />
</bean>
- <!-- 事务管理器
-->
- <bean id="htm" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
- <!-- 将事务代码以通知的形式织入业务类
-->
- <tx:advice id="ad" transaction-manager="htm">
- <tx:attributes>
<tx:method name="*" propagation="REQUIRED" />
</tx:attributes>
</tx:advice>
- <aop:config>
<aop:pointcut id="pc" expression="execution(public * tjy.hrm.biz.*.*(..))" />
<aop:advisor advice-ref="ad" pointcut-ref="pc" />
</aop:config>
</beans>
<aop:config>
<aop:pointcut id="txAdvicePointcut" expression="execution(public* com.nuist.service.*.*(..))"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="txAdvicePointcut"/>
</aop:config>