springAOP配置文件

  1 <?xml version="1.0" encoding="UTF-8"?>
  2 <beans
  3     xmlns="http://www.springframework.org/schema/beans"
  4     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  5     xmlns:aop="http://www.springframework.org/schema/aop"
  6     xmlns:tx="http://www.springframework.org/schema/tx"
  7     xmlns:p="http://www.springframework.org/schema/p"
  8     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
  9         http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
 10            http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd"> 
 11     <bean id="dataSource" class="org.apache.commons.dbcp2.BasicDataSource" destroy-method="close">
 12         <property name="driverClassName">
 13             <value>com.mysql.jdbc.Driver</value>
 14         </property>
 15         <property name="url">
 16             <value>jdbc:mysql://localhost:3306/ssh2</value>
 17         </property>
 18         <property name="username">
 19             <value>root</value>
 20         </property>
 21         <property name="password">
 22             <value>123456</value>
 23         </property>
 24     </bean>
 25     <!-- 配置sessionFactory -->
 26     <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
 27         <property name="dataSource" ref="dataSource"></property>
 28         <property name="hibernateProperties">
 29             <props>
 30                 <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
 31                 <prop key="hibernate.show_sql">true</prop>
 32             </props>
 33         </property>
 34         <property name="mappingResources">
 35             <list>
 36                 <value>com/zhanghaobo/bean/User.hbm.xml</value>
 37             </list>
 38         </property>
 39     </bean>
 40     <!-- 配置事务管理器 -->
 41     <bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
 42         <property name="sessionFactory" ref="sessionFactory"></property>
 43     </bean>
 44     <!-- 哪些类哪些方法使用事务 -->
 45     <aop:config>
 46         <!-- 定义在哪些方法上开启事务-->
 47         <aop:pointcut expression="execution(* com.zhanghaobo.service.impl.*.*(..))" id="allManagerMethod"/>
 48         <aop:advisor advice-ref="txAdvice" pointcut-ref="allManagerMethod"/>
 49         <aop:aspect id="authorAspect" ref="authorityInterceptor">
 50             <aop:before method="checkAuthor" pointcut-ref="allManagerMethod"/>
 51         </aop:aspect>
 52     </aop:config>
 53     <!-- 事务的传播特性  -->
 54     <tx:advice id="txAdvice" transaction-manager="transactionManager">
 55         <tx:attributes>
 56             <tx:method name="find*" propagation="REQUIRED" read-only="true" />
 57             <tx:method name="*" propagation="REQUIRED"/>
 58         </tx:attributes>
 59     </tx:advice>
 60     <bean id="authorityInterceptor" class="com.zhanghaobo.interceptor.AuthorityInterceptor">
 61         <property name="user">
 62             <value>aaa</value>
 63         </property>
 64     </bean>
 78     <bean id="userService" class="org.springframework.aop.framework.ProxyFactoryBean" >
 79         <property name="target" ref="userServiceTarget"></property>
 80         <property name="proxyInterfaces">
 81             <value>com.zhanghaobo.service.UserService</value>
 82         </property>
 83 
 84         <property name="interceptorNames">
 85             <value>authorityInterceptor</value>
 86         </property>
 87     </bean>
 88     <bean id="userDao" class="com.zhanghaobo.dao.impl.UserDAOImpl" scope="singleton">
 89         <property name="sessionFactory" ref="sessionFactory"></property>
 90     </bean>
 91     <bean id="userServiceTarget" class="com.zhanghaobo.service.impl.UserServiceImpl" scope="singleton">
 92         <property name="userdao" ref="userDao"></property>
 93     </bean>
 94     <bean id="saveUserAction" class="com.zhanghaobo.action.user.SaveUserAction" scope="prototype">
 95         <property name="userService" ref="userService"></property>
 96     </bean>
 97     <bean id="listUserAction" class="com.zhanghaobo.action.user.listUser" >
 98         <property name="userService" ref="userService"></property>
 99     </bean>
100 </beans>

 

转载于:https://www.cnblogs.com/oldcownotGiveup/p/5372066.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值