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的更多相关文章

  1. spring之初识Ioc&Aop

    Spring框架的作用 spring是一个轻量级的企业级框架,提供了ioc容器.Aop实现.dao/orm支持.web集成等功能,目标是使现有的java EE技术更易用,并促进良好的编程习惯. Spr ...

  2. 转:Spring历史版本变迁和如今的生态帝国

    Spring历史版本变迁和如今的生态帝国     版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/bntX2jSQfEHy7/article/deta ...

  3. Spring 使用xml配置aop

    1.xml文件需要引入aop命名空间 2.xml内容: <?xml version="1.0" encoding="UTF-8"?> <bea ...

  4. Spring MVC 中使用AOP 进行统一日志管理--注解实现

    1.AOP简介 AOP称为面向切面编程 AOP的基本概念 (1)Aspect(切面):通常是一个类,里面可以定义切入点和通知 (2)JointPoint(连接点):程序执行过程中明确的点,一般是方法的 ...

  5. [转]Spring历史版本变迁和如今的生态帝国

    前两篇: 为什么要有Spring? 为什么要有Spring AOP? 前两篇从Web开发史的角度介绍了我们在开发的时候遇到的一个个坑,然后一步步衍生出Spring Ioc和Spring AOP的概念雏 ...

  6. -手写Spring注解版本&事务传播行为

    视频参考C:\Users\Administrator\Desktop\蚂蚁3期\[www.zxit8.com] 0018-(每特教育&每特学院&蚂蚁课堂)-3期-源码分析-手写Spri ...

  7. spring boot: filter/interceptor/aop在获取request/method参数上的区别(spring boot 2.3.1)

    一,filter/interceptor/aop在获取参数上有什么区别? 1,filter可以修改HttpServletRequest的参数(doFilter方法的功能), interceptor/a ...

  8. Spring的IOC和AOP之深剖

    今天,既然讲到了Spring 的IOC和AOP,我们就必须要知道 Spring主要是两件事: 1.开发Bean:2.配置Bean.对于Spring框架来说,它要做的,就是根据配置文件来创建bean实例 ...

  9. Spring(6)—— AOP

    AOP(Aspect-OrientedProgramming)面向切面编程,与OOP完全不同,使用AOP编程系统被分为切面或关注点,而不是OOP中的对象. AOP的引入 在OOP面向对象的使用中,无可 ...

  10. 转-Spring Framework中的AOP之around通知

    Spring Framework中的AOP之around通知 http://blog.csdn.net/xiaoliang_xie/article/details/7049183 标签: spring ...

随机推荐

  1. C++并发-同步并发

    1.等待事件 std::mutex m; void wait() { std::unique_lock<std::mutex> lk(m); lk.unlock(); std::this_ ...

  2. 【eslint 插件开发】禁用 location 跳转外部链接

    背景 公司 h5 项目需要为跳转的外部链接统一增加参数.举个例子,假设有如下代码: location.href = 'https://www.test.com/a?id=xxx' location.r ...

  3. 数据对接:从Notion Database到低代码平台

    前言 Notion简介 近几年,有一款叫Notion的产品异常火爆,它是集笔记.任务管理.Wiki.数据管理为一体的产品,他主打两个理念「模块化」和「All-in-one」,Notion最有魅力的还是 ...

  4. Linux问题--docker启动mysql时提示3306端口被占用(kill不掉3306端口)

    使用kill -9 杀掉mysqld服务时一直失败. mysql启动时会启动mysqld和mysqld_safe两个进程,当使用kill -9杀掉mysqld进程时,mysqld_safe会自动重新启 ...

  5. Vue急速入门-5

    vue-cli创建项目 前端工程化,项目>>>(vue-cli),创建处vue项目,单页面应用(spa) vue-cli创建项目开发,在项目中开发,最后上线,一定要编译 '纯粹的ht ...

  6. ACR2022的辩论:DMARDs在pre-RA中的作用

    ACR2022的辩论:DMARDs在pre-RA中的作用 2022年11月13日   亚临床RA在风湿病学实践中越来越常见:然而,目前尚不清楚如何管理这些患者,以及启动DMARD是否可以预防RA的发展 ...

  7. [EULAR文摘] 超声对已获临床低活动度RA患者病情复发的预测

    标签:eular文摘; 超声评估; 病情预测 超声对已获临床低活动度RA患者病情复发的预测 Lamers-Karnebeek FBG, et al. EULAR 2015.Present ID: OP ...

  8. Vue框架整理:computed计算属性设置与缓存

    简单的一些小计算可以直接用模板内的表达式计算,比较复杂一点的就建议使用"计算属性来运算了",也方便后期的维护:vue所有的计算属性都以函数的形式写在Vue实例内的computed里 ...

  9. swiper弹出窗口居中效果css

    position: absolute; width: 800px; left: 50%; top: 50%; transform: translate(-50%, -50%);

  10. Java第四讲动手动脑

    1. 在以上的代码中,main方法调用的是public void println(Object x),这一方法调用了String类的valueOf方法,valueOf方法内部调用Object. toS ...