Spring框架—-可以理解为一个管理者,管理整个分层架构中的每一个对象
    框架—-别人封装好的供我们使用
    1.下载jar
    2.搭建到我们的开发环境中
    3.Spring最主要学习的内容
    IOC Inversion Of Control控制反转
    (DI) Dependency Injection依赖注入
    AOP Aspect Oriented Programming面向切面编程 (Object Oriented Programming)
    JDBC
    MVC

    下载地址:
    https://repo.spring.io/ui/native/libs-release-local/org/springframework/spring

    创建一个项目 搭建Spring环境

    1. 导包(根据需求导包,下方为最基础的几个包)

    image.png

    1. 配置文件

    ApplicationContext.xml

    1. <?xml version="1.0" encoding="UTF-8"?>
    2. <beans xmlns="http://www.springframework.org/schema/beans"
    3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    4. xsi:schemaLocation="http://www.springframework.org/schema/beans
    5. https://www.springframework.org/schema/beans/spring-beans.xsd">
    6. <bean name="student" class="domain.Student"></bean>
    7. </beans>


    1. 创建一个Bean工厂 ```java package test;

    import domain.Student; import org.springframework.beans.factory.BeanFactory; import org.springframework.context.support.ClassPathXmlApplicationContext;

    public class TestMain { public static void main(String[] args){ //将对象的控制权交给别人 //1.需要创建一个Spring用来管理bean对象的工厂 BeanFactory factory=new ClassPathXmlApplicationContext(“ApplicationContext.xml”); //2.帮我们创建对象,跟工厂要一个对象 Student student=(Student) factory.getBean(“student”); System.out.println(student); } } ``` image.png

    1. 对象的管理

    好多对象——-好多
    每一次创建的对象是new 单例
    对象中有属性——DI