首页 > 解决方案 > Spring Boot 拦截服务方法

问题描述

我有这个服务由 spring boot 管理

@Service
public class SystemSecuredServiceBean implements SystemSecuredService {

    @Override
    public <S extends BaseEntity> S save(S s) {           
        return null;
    }
}

我想在方法调用之前拦截,可以吗?

标签: spring-bootinterceptor

解决方案


是的,您可以将面向方面的编程 (AOP) 与直接集成在核心 Spring 框架中的 AspectJ 一起使用。

在您的情况下,@Before注释似乎合适。

有关详细信息,您可以阅读Spring AOP AspectJ @Before Annotation Example


推荐阅读