读书人

带事宜得spring配置文件

发布时间: 2012-08-25 10:06:20 作者: rapoo

带事务得spring配置文件

<?xml version="1.0" encoding="UTF-8" ?> - <!-- <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN"   --> - <!-- " http://www.springframework.org/dtd/spring-beans.dtd">   --> - <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.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"> - <!--  <bean id="sessionFactory"  --> - <!--   destroy-method="close">   <property name="driverClassName" value="com.microsoft.jdbc.sqlserver.SQLServerDriver" />   <property name="url" value="jdbc:microsoft:sqlserver://localhost:1433;DatabaseName=epet;SelectMethod=cursor" />   <property name="username" value="sa" />   <property name="password" value="pwd" />   </bean> - <bean id="sessionFactory" />   </property> - <property name="mappingResources"> - <list>   <value>com/aptech/jb/epet/entity/PetInfo.hbm.xml</value>   <value>com/aptech/jb/epet/entity/PetDiary.hbm.xml</value>   </list>   </property> - <property name="hibernateProperties"> - <props>   <prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>   <prop key="hibernate.show_sql">true</prop>   </props>   </property>   </bean> - <bean id="myHibTxManager" ref="sessionFactory" />   </bean> - <tx:advice id="txAdvice" transaction-manager="myHibTxManager"> - <tx:attributes> - <!--  对get/load/search开头的方法要求只读事务   -->   <tx:method name="get*" propagation="SUPPORTS" read-only="true" />   <tx:method name="load*" propagation="SUPPORTS" read-only="true" />   <tx:method name="search*" propagation="SUPPORTS" read-only="true" />   <tx:method name="find*" propagation="SUPPORTS" read-only="true" /> - <!--  对其它方法要求事务   -->   <tx:method name="*" propagation="REQUIRED" />   </tx:attributes>   </tx:advice> - <aop:config> - <!--    只对GoodsBiz添加事务支持,因为前面配置的transactionManager   是专对Hibernate的事务管理器 。  -->   <aop:pointcut id="bizMethods" expression="execution(* com.aptech.jb.epet.biz.*.*(..))" /> - <!--  织入   -->   <aop:advisor advice-ref="txAdvice" pointcut-ref="bizMethods" />   </aop:config> - <!--  DAO  --> - <bean id="petInfoDAO" ref="sessionFactory" />   </bean> - <bean id="petDiaryDAO" ref="sessionFactory" />   </bean> - <!--  BIZ  --> - <bean id="petInfoBiz" ref="petInfoDAO" />   </bean> - <bean id="petDiaryBiz" ref="petDiaryDAO" />   </bean> - <!--  ACTION  --> - <bean name="/pet" ref="petInfoBiz" />   </bean> - <bean name="/login" ref="petInfoBiz" />   </bean> - <bean name="/diary" ref="petDiaryBiz" />   </bean>   </beans> 

?

?

?

?

读书人网 >软件架构设计

热点推荐