springMVC与spring使用中,AOP失效的问题
2017-03-06 17:41
435 查看
在使用springMVC+spring+mybatis开发一个项目的时候,对整个项目进行事务管理,但是一直aop没有拦截到连接点,用了一天的功夫在网上寻找答案
在这个地址找到了答案
http://www.cnblogs.com/wcyBlog/p/4342077.html
解决的方法是,springMVC只扫描controller层的包,spring不扫描controller的包
详细的原因是,springMVC会先扫描加载,当springMVC扫描后,扫描过的部分,spring就不会去扫描了,于是spring中的AOP就不能发挥作用了。
在这个地址找到了答案
http://www.cnblogs.com/wcyBlog/p/4342077.html
解决的方法是,springMVC只扫描controller层的包,spring不扫描controller的包
<!-- 在springMVC --> <context:component-scan base-package="com"> <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Service" /> </context:component-scan> <!-- 在spring --> <context:component-scan base-package="com"> <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller" /> </context:component-scan>
详细的原因是,springMVC会先扫描加载,当springMVC扫描后,扫描过的部分,spring就不会去扫描了,于是spring中的AOP就不能发挥作用了。
相关文章推荐
- spring 整合struts2 使用 aop 碰到的问题
- 在Eclipse RCP中使用Spring AOP/ProxyFactory的问题
- 关于SpringMvc中使用aop的问题
- spring AOP使用注解无法执行的问题
- 关于使用Spring AOP 环绕性增强出现异常影响业务流程的问题
- 使用 spring aop 在DispatchAction中遇到的问题
- spring 声明式事务、异步调用、AOP灯增强类功能 失效问题
- 解决maven工程中使用spring-boot后导致的profile多环境配置失效的问题
- 关于spring和springmvc使用过程中的问题帖(持续更新)
- 使用springMVC + Spring进行web开发时,aop不生效的问题
- 使用spring的aop实现拦截action后出现依赖注入为空的问题
- spring的Aop使用问题
- 使用spring的aop实现拦截action后出现依赖注入为空的问题
- 笔记有关在spring使用aop在实现service层时出现的问题
- 几个问题(十)-------spring的IOC、AOP的使用场景
- Spring如何使用aop切入controller层---问题笔记
- 解决spring、springMVC重复扫描导致事务失效的问题
- springMVC配置spring AOP功能中遇到的问题
- struts2,spring整合中使用spring 管理struts2的action,springaop 常见问题
- dubbo2.5-spring4-mybastis3.2-springmvc4-mongodb3.4-redis3.2整合(四)Spring AOP中使用log4j实现http请求日志入mongodb