Spring 启动拦截服务方法

Spring boot intercept service methods

我有此服务由 spring boot

管理
@Service
public class SystemSecuredServiceBean implements SystemSecuredService {

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

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

是的,你可以使用直接集成在核心Spring框架中的Aspect-oriented Programming (AOP) with AspectJ

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

详情请阅读Spring AOP AspectJ @Before Annotation Example