Spring mvc Spring MVC中未调用方面

Spring mvc Spring MVC中未调用方面,spring-mvc,aop,aspectj,spring-aop,Spring Mvc,Aop,Aspectj,Spring Aop,我将我们的aspect、annotation和MVC控制器编写如下: 方面 @Aspect public class AuditAspect { @Around(value = "@annotation(com.test.Audit)") public Object audit(ProceedingJoinPoint pjp) { System.out.println("Inside the Audit aspect ..."); Object re

我将我们的aspect、annotation和MVC控制器编写如下:

方面

@Aspect
public class AuditAspect {

    @Around(value = "@annotation(com.test.Audit)")
    public Object audit(ProceedingJoinPoint pjp) {
       System.out.println("Inside the Audit aspect ...");
       Object result = null;
        try {
            result = pjp.proceed();
        } catch (Throwable t) {

        }
        return result;
    }
}
注释:

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface Audit
{
    AuditType auditType();
}
@RestController
@RequestMapping("/patients")
public class PatientController {

    @Audit(auditType = AuditType.PATIENT_LIST)
    @RequestMapping(value="", method=RequestMethod.GET)
    public APIResponse getPatients(HttpServletRequest request, HttpServletResponse response, @RequestParam(required = false, value="audit") String sAudit) {
       System.out.println("Inside getPatients ...");
       return null;
    }
}
控制器:

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.METHOD)
public @interface Audit
{
    AuditType auditType();
}
@RestController
@RequestMapping("/patients")
public class PatientController {

    @Audit(auditType = AuditType.PATIENT_LIST)
    @RequestMapping(value="", method=RequestMethod.GET)
    public APIResponse getPatients(HttpServletRequest request, HttpServletResponse response, @RequestParam(required = false, value="audit") String sAudit) {
       System.out.println("Inside getPatients ...");
       return null;
    }
}
但是,每当我发出rest请求时,不会调用aspect的审计方法

四处寻找帮助。发现很少有帖子提到AspectJ不使用SpringMVC控制器。然而,我用一个简单的SpringMVC应用程序尝试了同样的例子,并且该方面得到了正确的调用,即使控制器方法被注释。不确定这里出了什么问题。这里的任何提示/建议都会非常有用

我尝试的示例应用程序没有使用spring事务管理器,也没有与hibernate等集成。。。那会有什么不同吗

此外,下面给出了上下文文件条目:


为了使Spring AOP工作,方面和目标对象都必须是Spring
@组件