zoukankan      html  css  js  c++  java
  • Spring课程 Spring入门篇 5-2 配置切面aspect

    课程链接:

    本节主要讲了在xml中配置切面的demo

    1    解析

    1.1  配置切面xml

    1.2  运用什么原理

    2    代码演练

    2.1  配置切面xml

    1    解析

    1.1  配置切面xml

    spring的所有切面和通知器必须放在一个<aop:config>内(可以配置多个<aop:config>元素),每一个<aop:config>可以包含point、advisor和aspect元素(必须按照顺序声明)

    1.2  运用什么原理?

    <aop:config> 使用了Spring的自动代理机制

    2    代码演练

    2.1  配置切面xml

    xml配置:

    <?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: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-4.0.xsd">
    
    
    <bean id = "logAspect" class = "com.imooc.aop.schema.advice.MoocAspect"></bean>
    <bean id = "AspectBiz" class = "com.imooc.aop.schema.advice.biz.AspectBiz"></bean>
    
    <aop:config>
        <aop:aspect  id="moocAspectAOP" ref="logAspect"></aop:aspect>
    </aop:config>
    
    </beans>

    切面类:

    package com.imooc.aop.schema.advice;
    
    public class MoocAspect {
    
    }

    目标对象类:

    package com.imooc.aop.schema.advice.biz;
    
    public class AspectBiz {
    
    }
  • 相关阅读:
    系统引导管理器GRUB,为初学者指南
    PHPBB安装
    python的装饰器
    PIL的问题解决
    python的小技巧
    强烈推荐instagram的ppt
    新的一天
    OpenStack介绍
    ansible自动化运维工具
    .net连oracle的问题
  • 原文地址:https://www.cnblogs.com/1446358788-qq/p/10681023.html
Copyright © 2011-2022 走看看