spring AOP使用注解无法执行的问题
来源:互联网 发布:网络直播相关法律出台 编辑:程序博客网 时间:2024/06/04 19:31
spring AOP使用注解无法执行的问题
今天项目中想用spring的aop切面功能,代码如下:
定义一个简单的切面类
@Aspect@Component("loginInterceptor")public class LoginInterceptor {@Before("execution(* com.bibo.service.controller.TestAop.*(..))") public void before(){ System.err.println("method start..."); } }
spring的配置文件
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd"> <aop:aspectj-autoproxy/> <context:annotation-config /> <context:component-scan base-package="**.controller" /> <!-- 激活处理@ Controller类(注释支持驱动的格式和注释驱动的验证) --> <mvc:annotation-driven />
基本项目代码就是这样,但是测试的时候,切面就是不执行….
首先检查切面类和controller是否都被spring管理,经过检查,没问题…
各种检查切面语法,也没问题。
最后看到CSDN一个大神说:项目使用了spring mvc,把 <aop:aspectj-autoproxy/>
配置放到spring mvc的配置中,试了一下,果然可以了。
记录下来,以后千万记住!!
阅读全文
0 0
- spring AOP使用注解无法执行的问题
- 初学spring aop 注解遇到的问题
- 使用Spring的注解方式实现AOP
- 使用Spring的注解方式实现AOP
- 使用Spring的注解方式实现AOP
- Spring使用注解的方式实现AOP
- 使用Spring的注解方式实现AOP
- 使用Spring的注解方式实现AOP
- 使用Spring的注解方式实现AOP
- 使用Spring的注解方式实现AOP
- 注解方式使用spring aop的步骤
- Spring的注解Controller中使用AOP
- 使用Spring的注解方式实现AOP
- 使用Spring的注解方式实现AOP
- 使用Spring的注解方式实现AOP
- 使用Spring的注解方式实现AOP
- spring aop的annotation 注解使用
- 使用Spring的注解方式实现AOP
- DynamicMethodInvocation值
- Android源码及SDK国内镜像下载
- SIGHLD信号及其应用
- Git相关操作二
- SIFT特征点描述子生成(生成特征向量)
- spring AOP使用注解无法执行的问题
- spring的value获取不到值
- 全局异常捕获
- SpringBoot学习-持久化Quartz定时任务管理
- Git相关操作三
- 喜欢英语却不愿意付出行动
- hihocoder-1523
- 【图像融合】主成分分析PCA
- Git相关操作四