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 {
    
    }
  • 相关阅读:
    自主问题--KMP算法
    题解--luogu--CSP2019.S.Day2.T4--Emiya 家今天的饭
    浅谈——RMQ
    浅谈——LCA
    NOIP(si le)或者CSP初赛之——前序中序后序,前缀中缀后缀
    浅说——查分约束
    浅说——tarjan
    C++ RQNOJ 星门龙跃
    C++ 洛谷 1261:【例9.5】城市交通路网
    刷题
  • 原文地址:https://www.cnblogs.com/1446358788-qq/p/10681023.html
Copyright © 2011-2022 走看看