• 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 {
    
    }
  • 相关阅读:
    19.2.8 [LeetCode 53] Maximum Subarray
    19.2.8 [LeetCode 52] N-Queens II
    19.2.8 [LeetCode 51] N-Queens
    19.2.7 [LeetCode 50] Pow(x, n)
    19.2.7 [LeetCode 49] Group Anagrams
    19.2.7 [LeetCode 48] Rotate Image
    19.2.7 [LeetCode 47] Permutations II
    19.2.7 [LeetCode 46] Permutations
    19.2.7 [LeetCode 45] Jump Game II
    19.2.4 [LeetCode 44] Wildcard Matching
  • 原文地址:https://www.cnblogs.com/1446358788-qq/p/10681023.html
Copyright © 2020-2023  润新知