解决Spring MVC 对AOP不起作用的问题

用的是 SSM3的框架 Spring MVC 3.1 + Spring 3.1 + Mybatis3.1

第一种情况
Spring MVC 和 Spring 整合的时候,SpringMVC的springmvc.xml文件中 配置扫描包,不要包含 service的注解,Spring的applicationContext.xml文件中 配置扫描包时,不要包含controller的注解,如下所示:
SpringMVC的xml配置: <context:component-scan base-package="com.insigma">
  <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Service"/>
</context:component-scan>
启动时的配置文件,包含组件扫描、映射以及设置参数,让不扫描带有注解的类。为什么要这样设置?因为不是同时加载,如果不进行这样的设置,那么,spring@ServiceapplicationContext.xmlServicecglibServiceapplicationContext 中的事务配置不起作用,发生异常时,无法对数据进行回滚。以上就是原因所在。
同样的在Spring的xml配置如下:
<context:component-scan base-package="com.insigma">           
 <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
</context:component-scan>
@Controllerspringmvc.xml
注意以上几点就OK了。
这是转载文章...........
原文地址:https://www.cnblogs.com/zhaoxinshanwei/p/5769269.html