Aspect @annotation(PutMapping)不起作用

时间:2018-03-26 19:59:43

标签: java spring aop aspect

我在方面类中有以下代码。

    @Pointcut("execution(* com.api.webservice.controller.*.*(..)) " +
            "&& (@annotation(org.springframework.web.bind.annotation.PostMapping) || @annotation(org.springframework.web.bind.annotation.PutMapping) || @annotation(org.springframework.web.bind.annotation.DeleteMapping))")
    public void pointCut() {}

    @Around("pointCut()")
    public Object handleMethod(ProceedingJoinPoint pjp) throws Throwable {
         ......
    }

"PostMapping""DeleteMapping"都按预期工作(handleMethod()被点击)。但"PutMapping"似乎无法正常工作,因为当我通过邮递员发起“Put”休息电话时,handleMethod()没有被击中。我的方法原型是

    @PostMapping
    @ResponseStatus(value = HttpStatus.CREATED)
    public Entity create(@Valid @RequestBody Entity entity) {
        ...
    }

    @PutMapping("/{id}")
    public Entity update(@PathVariable String id, @Valid @RequestBody Entity entity) {
        ...
    }

    @DeleteMapping("/{id}")
    @ResponseStatus(value = HttpStatus.NO_CONTENT)
    public void deleteEntityById(@PathVariable String id) {
        ...
    }

有什么想法吗?

0 个答案:

没有答案
相关问题