在applicationContext.xml文件中的设置为:
1 <beans> 2 <bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"> 3 <property name="dataSource" ref="dataSource" /> 4 <!-- 注解的类太多了,可以采用packagesToScan来配置,直接扫描包--> 5 <property name="packagesToScan"> 6 <list> 7 <value>com.lcsoft.mobile.bean</value> 8 </list> 9 </property> 10 11 <property name="hibernateProperties"> 12 <props> 13 <prop key="hibernate.dialect">${hibernate.dialect}</prop> 14 <prop key="hibernate.show_sql">${hibernate.showsql}</prop> 15 </props> 16 </property> 17 </bean> 18 19 <!-- 定义事务管理器(声明式的事务) --> 20 <bean id="transactionManager" 21 class="org.springframework.orm.hibernate3.HibernateTransactionManager"> 22 <property name="sessionFactory" ref="sessionFactory" /> 23 </bean> 24 <tx:advice id="txAdvice" transaction-manager="transactionManager"> 25 <tx:attributes> 26 <tx:method name="*" propagation="REQUIRED" /> 27 </tx:attributes> 28 </tx:advice> 29 30 <aop:config> 31 <aop:pointcut id="interceptorPointCuts" 32 expression="execution(* com.mysoft.mobile.*.*(..))" /> 33 <aop:advisor advice-ref="txAdvice" 34 pointcut-ref="interceptorPointCuts" /> 35 </aop:config> 36 37 <bean id="SysUserService" 38 class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean" 39 abstract="true"> 40 <property name="transactionManager" ref="transactionManager" /> 41 <property name="transactionAttributes"> 42 <props> 43 <prop key="push*"> 44 PROPAGATION_SUPPORTS,readOnly,-DataAccessException,-BaseException 45 </prop> 46 </props> 47 </property> 48 </bean> 49 </beans>
时间: 2024-11-10 01:23:20