applicationContext.xml
发布时间:2020-12-16 00:41:38 所属栏目:百科 来源:网络整理
导读:?xml version="1.0" encoding="UTF-8"?!-- - Application context definition for JPetStore's business layer. - Contains bean references to the transaction manager and to the DAOs in - dataAccessContext-local/jta.xml (see web.xml's "contextConf
<?xml version="1.0" encoding="UTF-8"?> <!-- - Application context definition for JPetStore's business layer. - Contains bean references to the transaction manager and to the DAOs in - dataAccessContext-local/jta.xml (see web.xml's "contextConfigLocation"). --> <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.5.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd"> <!-- 建立sessionFactory --> <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> <property name="configLocation" value="classpath:hibernate.cfg.xml"></property> </bean> <!-- 声明事务管理 --> <bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory" /><!-- 引入sessionFactory --> </bean> <!-- 事务通知 --> <tx:advice id="txAdvice" transaction-manager="txManager"> <tx:attributes> <tx:method name="get*" read-only="true"/> <tx:method name="save*" propagation="REQUIRED"/> <tx:method name="update*" propagation="REQUIRED"/> </tx:attributes> </tx:advice> <aop:config> <!-- 定义哪些方法应用这些规则 --> <!-- 第一个*是返回值,第二个*是类,第三个*是方法,两点是参数 --> <aop:pointcut id="serviceMethod" expression="execution(* biz.impl.*.*(..))"/> <!-- 将事务通知与应用规则的方法组合 --> <aop:advisor advice-ref="txAdvice" pointcut-ref="serviceMethod"/> </aop:config> <bean id="userDao" class="dao.impl.UserDaoImpl"> <property name="sessionFactory" ref="sessionFactory"></property> </bean> <bean id="userBiz" class="biz.impl.UserBizImpl"> <property name="userDao" ref="userDao"></property> </bean> <bean id="userAction" class="action.UserAction"> <property name="userBiz" ref="userBiz"></property> </bean> </beans> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |