spring boot aop 报错

1、控制台报错

Pointcut is not well-formed: expecting 'name pattern' at character position 33 execution(com.stu.controller.*.*(..))

2、eclipse提示

Pointcut is malformed: Pointcut is not well-formed: expecting 'name pattern' at character position 33 execution(com.stu.controller.*.*(..)) 

上述两个错误是由路径配置不对造成的。

本来目的是要拦截 controller 包下的所有类的方法,配置为 @Before("execution(com.stu.controller.*(..))")、@Before("execution(com.stu.controller.*.*(..))"),结果报错,改为@Before("execution(* com.stu.controller.*.*(..))")即可。

“.*.*”,第一个“*”表示 controller 包下面的 controller 类,第二个“*”表示方法,所以第一次的配置不对,第二次的配置少了“*”,至于3个“*”中最前面的第一个“*”是什么意思,暂时还未明白。

参考文章:https://blog.csdn.net/yangxiaovip/article/details/31797475

猜你喜欢

转载自www.cnblogs.com/jingyi17/p/10159085.html