1).加入jar包:下载地址

  spring-beans-4.1.6.RELEASE.jar

  commons-logging-1.1.3.jar

  spring-context-4.1.6.RELEASE.jar

  spring-core-4.1.6.RELEASE.jar

  spring-expression-4.1.6.RELEASE.jar

  spring-aop-4.1.6.RELEASE.jar

  spring-aspects-4.1.6.RELEASE.jar

  aspectjweaver-1.5.2a.jar

  aopalliance-1.0.jar

  需要下载aspectj包,导入lib中的四个包

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAOUAAADeCAIAAABNFlAvAAAgAElEQVR4nO2deVQbV57v65+ePybz0vPOeTOvu9877fPOe93TM9NvXuJ00k1Plk63O3bS7tjGSxyDWYxxYmPHa9p4yWobO+0lxoBtFgFCSGLHGGMWSaB9ZbExAoEE2vddSAIk4X5/lJaSVGJxwFDkfs/n+BS3bt37q1tf3bqC+pWhn19s/fmF1p9daP3FxdZf5rX9vysPX/mm/a2btC132WmVoiM1g2fvSfLa5be6tRUcM4FrqeZaiFwLiWsmckwElqGKqcPTNZV0TSVdXdmjruhRV/SoyruV5TRlOU2Bo8pxVHkZZaKMMoGjystpyooedSVdi2foqph6AstQzTYS2IYqpg7P0Fb2qCt6VBXdqopuVXm3qqJbVdGjrqRrKhlaPEOHZ+qqWPoqlqGKZahi6auYuiqmroqhw4eoYumrOSYSz0IW2GuEjlqRs67XVd/nqu+bjNC7fLjqAMsPtEC/FnRrKzgWAs9K5NtIfBtZYCPzrSSehcQ1E7kmIsdUHcRYzTbCLiSwDASWvoqlr2Lqq5i6KpaewDZUs41EjonINZN4FhLPQuZbyTwriWcmciPHwodXs43VHGM1x0TkmolcM5FrIfEsJJ4VPpAULIwAt1YjsNeKgmat6402K/Ar9lmcX6v5NiLfThbYa4WOWqGjVmivEdhrBLYwZIGNzLeR+dYIYYfx4BK4pr1GGG4kqh0yH4EgVBlGaK8ROmqE9pq4fuFqtcFpNWxW4Ne1xkL8OprXLi/o1sF+JQnsNUJHncgZpjYWR63IgfBi0JHBDXjyiyN4YMxRIkdc40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CfgVCEsCfgXCkoBfgbAkkG8IhCWBfEMgLAnkGwJhSRjPN1wqPae/TaE/7rUIfe//hobxfMOlEvArRoTFfMOl0nI8nzJ3m9/Zr997YTHfcKkE/Io9LXW+Ifp/aBGfaheulnTjRsLn/1FaQckwWcq8xegTSbrRGuwSma6TOGNxrv9mMZJJFu450iFIaVyoljbfMNF/IBiTaod8aB+ZOxLWCv4/iVHnAoUzaqD4LIGESYXIgKJ7bM2Oaic+XwekNM6jJc03TPgfCEbbIaZagpvkyuQtop9Mou05kwpReoyx5hzpkCClEV1Lmm+Y8D8QXKRfVzJvEfUAtO15kwoX7leQ0rhgLWm+YcL/QDBmHBOsB8K3yBXMW0S/TaNtz59UGN8jml9BSuNitLT5hoE5v28haiES8iLftyJeWbm8xYX7NUGQkTZRekT1K0hpXIRWJN8wWs/+S541mrc4h7AS57JppfINo35X8Ky/e1mbeYtzCCtxLp9WJN8w6g74HcZ/zeUtziGsxLnMAs9rA2FJwK9AWBLwKxCWBPwKhCUBvwJhScCvQFgS8CsQlgT8CoQlAb8CYUnAr0BYEvArEJYE/AqEJQG/AmFJwK9AWBLwKxCW9P8BcNGUSu+uZVAAAAAASUVORK5CYII=" alt="" />

2).在配置文件中加入aop的命名空间

3).基于注解的方式

  1.在配置文件中加入如下配置:

  <aop:aspectj-autoproxy></aop:aspectj-autoproxy>

  2.把横切关注点的代码抽象到切面的类中

  • 切面首先是一个IOC中的bean,即加入@Component注解
  • 切面还需要加入@Aspect注解

  3.在类中声明各种通知:

  • 声明一个方法
  • 在方法前加入@Before注解

  4.可以再通知方法中声明一个类型为JoinPoint的参数,然后就能访问链接细节,如方法名称和参数值

代码:

package com.cn.spring.aop.impl;
//加减乘除的接口类
public interface ArithmeticCalculator {
int add(int i, int j);
int sub(int i, int j);
int mul(int i, int j);
int div(int i, int j);
}
package com.cn.spring.aop.impl;

import org.springframework.stereotype.Component;

//实现类
@Component
public class ArithmeticCalculatorImpl implements ArithmeticCalculator {
@Override
public int add(int i, int j) {
int result = i + j;
return result;
} @Override
public int sub(int i, int j) {
int result = i - j;
return result;
} @Override
public int mul(int i, int j) {
int result = i * j;
return result;
} @Override
public int div(int i, int j) {
int result = i / j;
return result;
}
}
package com.cn.spring.aop.impl;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.stereotype.Component; import java.util.Arrays;
import java.util.List; //把这个类声明为一个切面:首先需要把该类放入到IOC容器中,在声明为一个切面
@Aspect
@Component
public class LoggingAspect { //声明该方法是一个前置通知:在目标方法开始之前执行
@Before("execution(public int ArithmeticCalculator.*(int, int))")
public void beforeMethod(JoinPoint joinPoint) {
String methodName = joinPoint.getSignature().getName();
List<Object> args = Arrays.asList(joinPoint.getArgs()); System.out.println("The method " + methodName + " begins with " + args);
}
}
package com.cn.spring.aop.impl;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext; public class Main {
public static void main(String[] args) {
//1.创建Spring的IOC容器
ApplicationContext ctx = new ClassPathXmlApplicationContext("17-1.xml"); //2.从IOC容器中huo获取bean的实例
ArithmeticCalculator arithmeticCalculator = ctx.getBean(ArithmeticCalculator.class); //3.使用bean
int result = arithmeticCalculator.add(3, 6);
System.out.println("result:" + result);
}
}
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd">
<context:component-scan base-package="com.cn.spring.aop.impl">
</context:component-scan> <!--使AspjectJ注解起作用:自动为匹配的类生成代理对象-->
<aop:aspectj-autoproxy></aop:aspectj-autoproxy>
</beans>

17Spring前置通知的更多相关文章

  1. [原创]java WEB学习笔记106:Spring学习---AOP的通知 :前置通知,后置通知,返回通知,异常通知,环绕通知

    本博客的目的:①总结自己的学习过程,相当于学习笔记 ②将自己的经验分享给大家,相互学习,互相交流,不可商用 内容难免出现问题,欢迎指正,交流,探讨,可以留言,也可以通过以下方式联系. 本人互联网技术爱 ...

  2. 12Spring_AOP编程(AspectJ)_前置通知

    接下里的博客会一篇一篇的讲解每一个通知.其实AOP_AspectJ的编程与传统的AOP的编程的最大的区别就是写一个Aspect 支持多个Advice和多个PointCut .而且我们写AOP_Aspc ...

  3. Spring AOP前置通知和后置通知

    Spring AOP AspectJ:Java社区里最完整最流行的AOP框架 在Spring2.0以上的版本中,可以使用基于AspectJ注解或基于XML配置的AOP 在Spring中启用Aspect ...

  4. Spring AOP 前置通知

    我们使用AspectJ对Spring进行AOP操作,有两种方式,注解和XML配置方式,先在pom.xml中声明jar包 <dependencies> <dependency> ...

  5. Spring AOP前置通知实例说明AOP相关概念

    今天又看了下韩顺平的SpringAOP的讲解,讲解的很透彻.仿照视频自己使用下前置通知. 一.引出问题 有个接口TestServiceInter,有两个实现方法TestService和Test2Ser ...

  6. aop编程之前置通知

    aop( Aspect-Oriented Programming)前置通知原理案例讲解 编程步骤: 定义接口 编写对象(被代理的对象即目标对象) 编写通知(前置通知即目标方法调用前调用) 在beans ...

  7. AOP 和 前置通知,后置通知

    Spring 1.AOP:中文名称面向切面编程 2.英文名称:(Aspect Oriented Programming) 3.正常程序执行流程都是纵向执行流程 3.1 又叫面向切面编程,在原有纵向执行 ...

  8. Spring AOP前置通知实例讲解与AOP详细解析

    一.引出问题 有个接口TestServiceInter,有两个实现方法TestService和Test2Service.他们都有sayHello():我们的需求是在调用这两个方法之前,要先完成写日志的 ...

  9. Spring初学之xml实现AOP前置通知、后置通知、返回通知、异常通知等

    实现两个整数的加减乘除,在每个方法执行前后打印日志. ArithmeticCalculator.java: package spring.aop.impl.xml; public interface ...

随机推荐

  1. Linux 常用命令五 软链接和硬链接

    一.软链接 相当于windows的快捷方式,当源文件不存在时,软链接失效. 创建软链接: wang@wang:~/workpalce/python$ ls -l 总用量 -rw-rw-r-- wang ...

  2. 购买阿里云ECS+安装宝塔面板+Mac下怎么连接阿里云ECS服务器

    1.购买阿里云ECS 2.重置实例密码 这个有点对用户不友好,实际意思就是设置服务器的root登录密码 3.配置安全组放行端口 因为服务器需要从宝塔网站download安装包,包括一些常用的服务比如S ...

  3. linux下tab键在命令行情况下的强大

    tab自动补全命令,包括可以补全比较长的文件名,速度快的不是一点点

  4. #undef及其用法

    简    介 在后面取消以前定义的宏定义 在此程序中,我们将取消在先前程序中对预处理器的定义. #include <stdio.h> int main( void ) { #define ...

  5. Java-String 类的常用方法

    Java 中 String 类的常用方法 Ⅰ String 类提供了许多用来处理字符串的方法,例如,获取字符串长度.对字符串进行截取.将字符串转换为大写或小写.字符串分割等,下面我们就来领略它的强大之 ...

  6. _bzoj1001 [BeiJing2006]狼抓兔子【平面图】

    传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=1001 顺便推荐一个ppt,里面有对平面图的介绍:浅析最大最小定理在信息学竞赛中的应用. 这里 ...

  7. 434 Number of Segments in a String 字符串中的单词数

    统计字符串中的单词个数,这里的单词指的是连续的非空字符.请注意,你可以假定字符串里不包括任何不可打印的字符.示例:输入: "Hello, my name is John"输出: 5 ...

  8. Uncaught TypeError: Cannot set property 'f7View' of undefined 错误原因

    // 添加视图var mainView = myApp.addView('.view-main', { // 因为我们要用动态的导航栏,我们需要使它的这一观点: dynamicNavbar: true ...

  9. API系列一:REST和RESTful认识

    序言 最近工作的项目一直使用API,就想趁這个机会,把API的知识点进行一次梳理和总结,顺便提升一下自己对API全新的认识 Web API 是ASP.NET平台新加的一个特性,它可以简单快速地创建We ...

  10. redis-3.0.1 sentinel 主从高可用 详细配置

    最近项目上线部署,要求redis作高可用,由于redis cluster还不是特别成熟,就选择了redis sentinel做高可用.redis本身有replication,实现主从备份.结合sent ...