spring-boot - Spring Boot 拦截服务方法
问题描述
我有这个服务由 spring boot 管理
@Service
public class SystemSecuredServiceBean implements SystemSecuredService {
@Override
public <S extends BaseEntity> S save(S s) {
return null;
}
}
我想在方法调用之前拦截,可以吗?
解决方案
是的,您可以将面向方面的编程 (AOP) 与直接集成在核心 Spring 框架中的 AspectJ 一起使用。
在您的情况下,@Before
注释似乎合适。
有关详细信息,您可以阅读Spring AOP AspectJ @Before Annotation Example。
推荐阅读
- mysql - 更新查询中的增量在表中添加 2 而不是 1
- android - 离子原生插件升级到 WKWebView 后停止工作
- javascript - 如何使用 ReactNative WebView 组件在我的 Android 应用程序中显示网页的特定部分?
- c# - 如何在c#中使用restclient处理嵌套查询
- powershell - 在 PowerShell 中添加对象属性的值,而无需按名称访问每个属性
- java - 在java中读取和写入文件
- asp.net-mvc - UnauthorizedAccessException 使用需要访问令牌的 API
- c# - 如何简化下面的 LookUp 命令?
- mongodb - 使用 Hibernate OGM 5.3 将多个文档插入 MongoDB
- jquery - jQuery 验证器自定义方法未定义 *有时*