Spring不同版本的AOP
1、Spring4、SpringBoot1
1.1 代码实现
- public interface Calculator {
- int div(int a,int b);
- }
- @Component
- public class CalculatorImpl implements Calculator{
- @Override
- public int div(int a, int b) {
- int result = a/b;
- System.out.println("计算结果为:"+result);
- return result;
- }
- }
- @Aspect
- @Component
- public class CalculatorAspect {
- @Before(value = "execution(* com.jixian.springboot1.CalculatorImpl.*(..))")
- public void beforeNotify(){
- System.out.println("@Before...前置通知");
- }
- @After(value = "execution(* com.jixian.springboot1.CalculatorImpl.*(..))")
- public void afterNotify(){
- System.out.println("@After...后置通知");
- }
- @AfterReturning(value = "execution(* com.jixian.springboot1.CalculatorImpl.*(..))")
- public void afterReturningNotify(){
- System.out.println("@AfterReturning...返回通知");
- }
- @AfterThrowing(value = "execution(* com.jixian.springboot1.CalculatorImpl.*(..))")
- public void afterThrowingNotify(){
- System.out.println("@AfterThrowing...异常通知");
- }
- @Around(value = "execution(* com.jixian.springboot1.CalculatorImpl.*(..))")
- public Object aroundNotify(ProceedingJoinPoint joinPoint) throws Throwable{
- Object res = null;
- System.out.println("@Around...环绕通知之前A");
- res = joinPoint.proceed();
- System.out.println("@Around...环绕通知之后B");
- return res;
- }
- }
1.2 测试
- @SpringBootTest
- @RunWith(SpringRunner.class)
- public class SpringBoot1ApplicationTests {
- @Autowired
- private Calculator calculator;
- @Test
- public void contextLoads() {
- System.out.println("Spring版本:"+ SpringVersion.getVersion()+"\t"+"SpringBoot版本:"+ SpringBootVersion.getVersion());
- calculator.div(5,2);
- }
- }
2、Spring5、SpringBoot2
3、Spring6、SpringBoot3
Spring不同版本的AOP的更多相关文章
- spring之初识Ioc&Aop
Spring框架的作用 spring是一个轻量级的企业级框架,提供了ioc容器.Aop实现.dao/orm支持.web集成等功能,目标是使现有的java EE技术更易用,并促进良好的编程习惯. Spr ...
- 转:Spring历史版本变迁和如今的生态帝国
Spring历史版本变迁和如今的生态帝国 版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/bntX2jSQfEHy7/article/deta ...
- Spring 使用xml配置aop
1.xml文件需要引入aop命名空间 2.xml内容: <?xml version="1.0" encoding="UTF-8"?> <bea ...
- Spring MVC 中使用AOP 进行统一日志管理--注解实现
1.AOP简介 AOP称为面向切面编程 AOP的基本概念 (1)Aspect(切面):通常是一个类,里面可以定义切入点和通知 (2)JointPoint(连接点):程序执行过程中明确的点,一般是方法的 ...
- [转]Spring历史版本变迁和如今的生态帝国
前两篇: 为什么要有Spring? 为什么要有Spring AOP? 前两篇从Web开发史的角度介绍了我们在开发的时候遇到的一个个坑,然后一步步衍生出Spring Ioc和Spring AOP的概念雏 ...
- -手写Spring注解版本&事务传播行为
视频参考C:\Users\Administrator\Desktop\蚂蚁3期\[www.zxit8.com] 0018-(每特教育&每特学院&蚂蚁课堂)-3期-源码分析-手写Spri ...
- spring boot: filter/interceptor/aop在获取request/method参数上的区别(spring boot 2.3.1)
一,filter/interceptor/aop在获取参数上有什么区别? 1,filter可以修改HttpServletRequest的参数(doFilter方法的功能), interceptor/a ...
- Spring的IOC和AOP之深剖
今天,既然讲到了Spring 的IOC和AOP,我们就必须要知道 Spring主要是两件事: 1.开发Bean:2.配置Bean.对于Spring框架来说,它要做的,就是根据配置文件来创建bean实例 ...
- Spring(6)—— AOP
AOP(Aspect-OrientedProgramming)面向切面编程,与OOP完全不同,使用AOP编程系统被分为切面或关注点,而不是OOP中的对象. AOP的引入 在OOP面向对象的使用中,无可 ...
- 转-Spring Framework中的AOP之around通知
Spring Framework中的AOP之around通知 http://blog.csdn.net/xiaoliang_xie/article/details/7049183 标签: spring ...
随机推荐
- vscode + vim 快捷键
多行编辑 按V选中行,按大写I即可进入编辑模式 撤销恢复 CTRL + z 撤销 CTRL + shift + z 恢复 代码自动对齐 Alt + shift + f
- 视觉十四讲:第七讲_ORB特征点
1.特征点 特征点是图像里一些特别的地方,如角点.边缘和区块.比较著名有SIFT.SURF.ORB等.SIFT充分考虑了图像变换过程中出现的光照.尺度.旋转等变换,但是计算量非常大.而ORB是质量和性 ...
- css 显示n行文字的方法 超出的部分用省略号代替
// 超出的部分用省略号代替 text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 1; // 显示文字的行数 over ...
- 我Alfred Workflow工具集合
MyToolBox 我常用的工具箱,Alfred Workflow工具集合满足日常开发使用场景.不断完善和更新Alfred Workflow. 目前包含一下功能. 时间戳转换 unicode转中文 随 ...
- JZOJ 1967.【2011集训队出题】聪聪可可
题目 [2011集训队出题]聪聪可可 思路 看看做做 阴阳 这道题 极力推荐 自从做了这道题后,这些题就变成秒切的题了 很容易想到求节点到分治中心的距离,然后 \(\bmod 3\) 那么在求根节点一 ...
- MyBatis 查询的条目与预期的不一致
预期查询的数据条目是 4 条: 但是 MyBatis 查询出来的结果只有 2 条数据: resultMap 开启了 autoMapping 功能,就不需要多余地添加 result.下面是错误的映射操作 ...
- nginx编译安装以及常用参数详解
1 基于ansible role实现编译安装nginx 利用ansible控制端10.0.0.8机器,在被控制端10.0.0.18上部署nginx 首先打通ansible控制端与被控制端的基于key验 ...
- 人工智能,丹青圣手,全平台(原生/Docker)构建Stable-Diffusion-Webui的AI绘画库教程(Python3.10/Pytorch1.13.0)
世间无限丹青手,遇上AI画不成.最近一段时间,可能所有人类画师都得发出一句"既生瑜,何生亮"的感叹,因为AI 绘画通用算法Stable Diffusion已然超神,无需美术基础,也 ...
- LeetCode-1001 网格照明
来源:力扣(LeetCode)链接:https://leetcode-cn.com/problems/grid-illumination 题目描述 在大小为 n x n 的网格 grid 上,每个单元 ...
- rust 计算两个经纬度的距离
依赖库 math_adapter={ version = "0.3.1", features = [ "cgmath_ops" ] } 实现 use math_ ...