5.AspectJ AOP 切面编程 (注解配置 )
新建 spring3 web 项目, 导入spring AOP开发jar包
5.1.编写Advice增强
配置applicationContext.xml
<!--注解配置切面-->
<aop:aspectj-autoproxy/>
使用注解修饰Advice类
@Aspect 这是一个切面
@Before 前置通知
@AfterReturning 后置通知
@Around 环绕通知
@AfterThrowing 抛出通知
@After最终通知
@Pointcut 切入点
小结:
1、注册Bean <context:component-scan> (@Service、@Controller、 @Repository 、@Component )
2、声明具有增强方法类是一个切面 @Aspect
3、在对应方法上,声明各种通知 @Before @AfterReturning @Around @AfterThrowing @After
4、 根据切面注解自动生成代理 <aop:aspectj-autoproxy />
新建 spring3 web 项目, 导入spring AOP开发jar包
5.1.编写Advice增强
配置applicationContext.xml
<!--注解配置切面-->
<aop:aspectj-autoproxy/>
使用注解修饰Advice类
@Aspect 这是一个切面
@Before 前置通知
@AfterReturning 后置通知
@Around 环绕通知
@AfterThrowing 抛出通知
@After最终通知
@Pointcut 切入点
小结:
1、注册Bean <context:component-scan> (@Service、@Controller、 @Repository 、@Component )
2、声明具有增强方法类是一个切面 @Aspect
3、在对应方法上,声明各种通知 @Before @AfterReturning @Around @AfterThrowing @After
4、 根据切面注解自动生成代理 <aop:aspectj-autoproxy />