Springboot切面问题

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/menggudaoke/article/details/82432272

切面问题:

@Before切面定义到service上,有的切面执行正常,但有的每次都是先执行service后执行切面,这个不知道为什么。

把切面定义到Controller上就好了,这个实在不知道是什么原因。

切面类:

@Aspect
@Order(3)
@Component
public class DataSourceAspect {
    private Logger logger = LoggerFactory.getLogger(this.getClass());

    //切点
    @Pointcut("execution(* com.hui.controller..*.*(..)))")
    public void aspect(){}

    @Before("aspect()")
    private void before(JoinPoint joinPoint){
        System.out.println("before切面执行");
    }
}

把切入点定义到service上始终有几个service的切入点不能正常执行,都是在执行完service之后才执行切面的内容,很奇怪,目前不知道是什么原因。

之前的切入点: @Pointcut("execution(* com.hui.controller..*.*(..)))")

有没有人遇到过相同的情况?一起来探讨下!

猜你喜欢

转载自blog.csdn.net/menggudaoke/article/details/82432272