1.基于aspectj的注解aop操作
public class Book{
public void add (){
System.out .pritnln("add.........." );
}
}
@Aspect
public class MyBook{
@Before(value ="execution(* po.Book.*(..))" )
public void berfore (){
System.out .pritnln("before........" );
}
}
配置文件
<beans xmlns ="http://www.springframework.org/schema/beans"
xmlns:xsi ="http://www.w3.org/2001/XMLSchema-instance"
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/aop http://www.springframework.org/schema/aop/spring-aop.xsd"
<!-- bean definitions here -- >
第一步
<bean id ="book" class ="aop.Book" > </bean >
<bean id ="mybook" class ="aop.myBook" > </bean >
第二部
开启安排操作 开启自动代理
<aop:aspectj-autoproxy > </aop:aspectj-autoproxy >
第三步在增强类上面使用注解完成安排操作、
</beans >