zoukankan      html  css  js  c++  java
  • spring-注解配置-junit整合测试-aop

    1 使用注解配置spring

    1.1 步骤

    导包4+2+spring-aop

    1.为主配置文件引入新的命名空间(约束)

    2.开启使用注解代理配置文件

    3.在类中使用注解完成配置

    1.2 将对象注册到容器

    1.3 修改对象的作用范围

    1.4 值类型注入

    通过反射的Field赋值,破坏了封装性

    通过set方法赋值,推荐使用.

     

    1.5 引用类型注入

    第一种

    第二种

    第三种★★

    1.6 初始化|销毁方法

    2 spring与junit整合测试

    1.导包4+2+aop+test

    2.配置注解

     

    3.测试

     

    3 spring中的aop

    3.1 aop思想介绍

     

     

    3.2 spring中的aop概念

    3.3 spring实现aop的原理

    动态代理(优先)

    被代理对象必须要实现接口,才能产生代理对象.如果没有接口将不能使用动态代理技术

    cglib代理(没有接口)

    第三方代理技术,cglib代理.可以对任何类生成代理.代理的原理是对目标对象进行继承代理. 如果目标对象被final修饰.那么该类无法被cglib代理.

    3.4 aop名词学习

    4 spring中的aop演示

    4.1 步骤(xml配置)

    1.导包4+2

    spring的aop包

    spring-aspects-4.2.4.RELEASE.jar

    spring-aop-4.2.4.RELEASE.jar

    spring需要第三方aop包

    com.springsource.org.aopalliance-1.0.0.jar

    com.springsource.org.aspectj.weaver-1.6.8.RELEASE.jar

    2.准备目标对象

    3.准备通知

     

    4.配置进行织入,将通知织入目标对象中

     4.2 步骤(注解配置)

    1.导包4+2

    同4.1

    2.准备目标对象

    同4.1

    3.准备通知

    同4.1

    4.配置进行织入,将通知织入目标对象中


    作者:8亩田
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接.

    本文如对您有帮助,还请多帮 【推荐】 下此文。
    如果喜欢我的文章,请关注我的公众号
    如果有疑问,请下面留言

    学而不思则罔 思而不学则殆
  • 相关阅读:
    mac c++编译出现segmentation fault :11错误
    ssh 连接缓慢解决方法
    237. Delete Node in a Linked List
    203. Remove Linked List Elements
    Inversion of Control Containers and the Dependency Injection pattern
    82. Remove Duplicates from Sorted List II
    83. Remove Duplicates from Sorted List
    SxsTrace
    使用CCleaner卸载chrome
    decimal and double ToString problem
  • 原文地址:https://www.cnblogs.com/liu-wang/p/8796824.html
Copyright © 2011-2022 走看看