Spring发展史

各个阶段使用的技术

EJB

JAVA主流框架演变之路

 

 任何一个语言或者任何一个框架想要立于不败之地,很重要的就是它的生态

 核心解释

 使用spring优点

 如何简化开发

 IOC 控制反转,ioc是一种设计思想

 DI与IOC

 

 解耦

 

 绿框是模块,黑色框表示所依赖的jar包

 

 xml 配置文件,bean

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
        https://www.springframework.org/schema/beans/spring-beans.xsd">

    <bean id="..." class="...">  
        <!-- collaborators and configuration for this bean go here -->
    </bean>

    <bean id="..." class="...">
        <!-- collaborators and configuration for this bean go here -->
    </bean>

    <!-- more bean definitions go here -->

</beans>

applicationContext:表示IOC容器入口,想要获取对象的话,必须要创建该类

项目配置的时候,可以使用xml也可以使用注解的方式

日常工作中,一般都是使用name,value的方式,很少有人使用index或者type的方式

p命名空间

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xmlns:p="http://www.springframework.org/schema/p"
    xsi:schemaLocation="http://www.springframework.org/schema/beans
    https://www.springframework.org/schema/beans/spring-beans.xsd">

    <bean id="myDataSource" class="org.apache.commons.dbcp.BasicDataSource"
        destroy-method="close"
        p:driverClassName="com.mysql.jdbc.Driver"
        p:url="jdbc:mysql://localhost:3306/mydb"
        p:username="root"
        p:password="misterkaoli"/>

</beans>
论读书
睁开眼,书在面前
闭上眼,书在心里
原文地址:https://www.cnblogs.com/YC-L/p/14227406.html