spring AOP事务

 1  <bean id="tttt" class="com.ry.project.dataSouces.UserLogger"/>
 2             <aop:config>
 3                 <!-- 定义一个切入点 -->
 4                 <aop:pointcut id="services" expression="execution (* com.ry.project.service.impl.*.*(..))" />
 5                 <!-- 对切入点和事务的通知,进行适配 -->
 6                 <aop:aspect ref="tttt">
 7                     <aop:before method="sayBefore" pointcut-ref="services"/>
 8                     <aop:after method="sayAfter" pointcut-ref="services"/>
 9                 </aop:aspect>
10             </aop:config>
View Code

 

 * com.ry.project.service.impl.*.*(..)//这个包下所有类的所有方法
    * com.ry.project.service.impl..*.*(..)//这个包及其子包所有类的所有方法
    public int  addUser(..)// “..”表示匹配所有参数个数和类型
    public  *  addUser(com.ry.project.vo.Order)//表示匹配所有返回类型
    public void *(com.ry.project.vo.Order)//表示匹配所有方法名





<aop:config>
        <!-- 定义一个切入点 -->
        <aop:pointcut id="services"
                      expression="execution (com.ry.project.service.impl.**(*))" />
        <!-- 对切入点和事务的通知,进行适配 -->
        <aop:advisor advice-ref="txAdvice" pointcut-ref="services" />
    </aop:config>
    advisor一搬用于事务AOP  aspect用于面向编程AOP

 

posted @ 2020-03-22 15:33  余生请多指教ANT  阅读(164)  评论(0编辑  收藏  举报