• Spring 源码学习(一)


    工作好多年了,越来越心浮气躁了,好多东西都是一知半解的,所以现在需要静下心来好好学习一门技术。

    就选Spring了, spring 设计java 开发的方方面面。

    期待目标 对Spring 有个更深层次的理解,理解Spring中使用的设计模式。

    开始了。

    ApplicationContext 是Spring的IOC容器。所有的对象都需要从IOC容器中获取,所以ApplicationContext的作用非常的重要。

    文件加载方式初始化的两个实现类

    FileSystemXmlApplicationContext
    ClassPathXmlApplicationContext

    注解方式实现的

    AnnotationConfigApplicationContext

    通过IOC容器获取实例Bean的两种方式

    1. byName

    2. byType

    自动装配也有两种方式

    1. byName

    2. byType

    bean属性配置的继承,表示的是配置被继承

    abstract 为 true 说明 bean id="parent" 的bean不能够被实例化

    deponds-on 设置前置依赖的bean

    <beans>
        <bean id="parent" abstract="true" class="example.ComplexObject">
            <property name="adminEmails">
                <props>
                    <prop key="administrator">administrator@example.com</prop>
                    <prop key="support">support@example.com</prop>
                </props>
            </property>
        </bean>
        <bean id="child" parent="parent">
            <property name="adminEmails">
                <!-- the merge is specified on the child collection definition -->
                <props merge="true">
                    <prop key="sales">sales@example.com</prop>
                    <prop key="support">support@example.co.uk</prop>
                </props>
            </property>
        </bean>
    <beans>

     属性文件外置:

    PropertyPlaceholderConfigurer
    <context:property-placeholder location="classpath:com/foo/jdbc.properties"/>

    加载外置配置文件

  • 相关阅读:
    你真的了解JSON吗?
    FormData对象
    javascript类数组
    Windows环境下XAMPP的相关设置
    PhpStorm相关设置
    yarn 与 npm 比较
    JavaScript+HTML+CSS 无缝滚动轮播图的两种方式
    javascript数据类型和类型转换
    焦大:以后seo排名核心是用户需求点的挖掘
    焦大:seo思维进化论(番外)
  • 原文地址:https://www.cnblogs.com/mengjianzhou/p/9123993.html
Copyright © 2020-2023  润新知