Spring-AOP-AOP操作(准备)

Spring-AOP-AOP操作(准备)

1、Spring框架一般都是基于AspectJ实现AOP操作

(1)什么是AspectJ

  AspectJ不是spring组成部分,独立AOP框架,一般把AspectJ和Spring框架一起使用,进行AOP操作

 

2.基于AspectJ实现AOP

(1)基于XML配置文件实现

 

(2)基于注解方式实现(使用)

 

3.在项目工程里面引入AOP相关依赖

spring-context-5.2.8.RELEASE.jar

spring-expression-5.2.8.RELEASE.jar

spring-context-5.2.8.RELEASE-sources.jar

commons-logging-1.1.1.jar

spring-core-5.2.8.RELEASE.jar

spring-beans-5.2.8.RELEASE.jar

spring-aspects-5.2.8.RELEASE.jar

spring-aop-5.2.8.RELEASE.jar

com.springsource.org.aopalliance-1.0.0.jar

com.springsource.org.aspectj.weaver-1.6.8.RELEASE.jar

com.springsource.net.sf.cglib-2.2.0.jar

4.切入点表达式

(1)切入点表达式作用:知道对哪个类里面的哪个方法进行增强。

(2)语法结构

  execution([权限修饰符][返回类型][类全路径][方法名称][参数列表])

 

举例一:对com.orz.dao.BookDao类里面的add进行增强

    execution(* com.orz.dao.BookDao.add(..))

举例二:对com.orz.dao.BookDao类里面的所有方法进行增强

    execution(* com.orz.dao.BookDao.*(..))

举例三:对com.orz.dao包里面所有类里面的所有方法进行增强

    execution(* com.orz.dao.*.*(..))

posted @ 2020-08-17 22:48  orz江小鱼  阅读(112)  评论(0编辑  收藏  举报