springboot使用AOP
来源:互联网 发布:网王之数据涟漪了 编辑:程序博客网 时间:2024/06/06 02:36
1、添加依赖
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-aop</artifactId></dependency>
2、设置切面
@Aspect@Configurationpublic class AopConfig { @Pointcut("execution(* com.glodon.springboot.controller.AopController.test*(..))") public void excudeService(){} @Before("excudeService()") public void before() { System.out.println("切面before执行了"); } @After("excudeService()") public void after() { System.out.println("切面after执行了"); } @AfterReturning("excudeService()") public void afterReturning() { System.out.println("切面afterReturning执行了"); } @AfterThrowing("excudeService()") public void afterThrowing() { System.out.println("切面afterThrowing执行了"); } @Around("excudeService()") public Object around(ProceedingJoinPoint thisJoinPoint){ Object obj = null; System.err.println ("切面around before执行了"); try { thisJoinPoint.proceed(); } catch (Throwable e) { e.printStackTrace (); } System.err.println ("切面around after执行了"); return obj; } }
3、测试类
@RestController@RequestMapping(value = "/api/aop")public class AopController { @GetMapping(value = "/test") public String testAOP() { System.out.println("test"); return "test"; }}
4、AOP顺序
通过注解方式配置AOP是无序的,若想有序则需显式定义一个Advisor的实现了Ordered的子类的bean,并且给order赋值
更多:
SpringBoot简介
SpringBoot-HelloWorld
spring boot 框架解析
spring boot 部署、启动
spring boot配置文件
spring boot 全局异常捕捉
springboot使用fastjson
springboot使用定时任务、异步
springboot使用AOP
springboot使用拦截器
springboot输出日志
springboot集成hibernate-jpa方式
阅读全文
0 0
- springboot使用AOP
- SpringBoot中aop的使用
- SpringBoot 使用AOP处理请求
- SpringBoot中使用AOP 监控sql耗时
- springboot 使用CGLib 方式实现AOP代理
- SpringBoot中使用AOP 监控sql耗时
- springboot学习(7)springboot使用AOP打印日志信息
- springboot-AOP
- SpringBoot-AOP
- springBoot aop
- eclipse 使用maven 构建springboot+mybatis+多数据源+aop
- SpringBoot中表单验证及Aop及异常的使用
- 使用拦截器(intercept)和AOP写操作日志-springboot
- springboot-aop访问拦截
- Springboot配置aop
- 第四十章 SpringBoot AOP
- springboot集成AOP
- SpringBoot aop demo
- 运用XML建立零件BOM
- Mybatis的sql封装
- 牛牛的数值变换
- 配置项---java环境变量的配置
- 一周乱弹: jquery validate 手动触发方式
- springboot使用AOP
- Oracle 11g数据库详细安装步骤图解
- 输出9 * 9乘法口诀
- springboot使用拦截器
- Qt客户服务端传输数据总结
- leetcode-第十七周
- Pagodas --(hdu5512)2015ACM/ICPC亚洲区沈阳站
- 欢迎使用CSDN-markdown编辑器
- thingsboard安装及配置