您的位置:首页 > 编程语言 > Java开发

探秘Spring AOP (二) Spring AOP 使用讲解 1

2017-10-23 00:00 357 查看

探秘Spring AOP

一、Spring AOP 使用方式

1,XML配置

2,注解方式



二、主要注解



代码演示

@Aspect
@Component
public class SecurityAspect {

@Autowired
private AuthService authService;

@Pointcut("@annotation(AdminOnly)")
public void adminOnly(){}

@Before("adminOnly()")
public void check(){
authService.checkAccess();
}
}

三、切面

1、PointCut express 切面表达式

2、 5种advice
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: