1.Spring框架是什么?

Spring是一个开放源代码的设计层面框架,他解决的是业务逻辑层和其他各层的松耦合问题,引起它将面向接口的编程思想贯穿整个系统应用

2.Spring的架构

【Spring框架】Spring框架介绍

3.最新的spring的技术

Springboot、Springcould

4.Spring的核心功能?

a)IOC:依赖注入/控制反转(好莱坞模式:你不用来找我,我需要的时候会去找你)

有几种IOC的实现方式:
(1)使用setter方法进行对象注入

(2)使用构造方法进行对象的注入

(3)使用新接口的方式进行对象的注入

Spring的IOC的配置:

(1)导入jar包

commons-logging-1.1.3.jar  、spring-beans-4.0.0.RELEASE.jar 、spring-context-4.0.0.RELEASE.jar 、

spring-core-4.0.0.RELEASE.jar 、spring-expression-4.0.0.RELEASE.jar  

(2)在src目录下编写spring的配置文件(默认名称:applicationContext.xml)

<!-- 配置IOC -->

         <!--

                   <bean>标签:代表一个被spring容器管理的对象

                   class属性:这个被管理对象的所属类

                   id属性:这个对象在spring容器中的标记

                   property属性:这个对象中需要被注入内容的属性

                   value属性:这个对象中需要被注入内容的属性注入的属性值

          -->

         <bean id="helloBean" class="com.svse.bean.HelloBean">

                   <property name="helloString" value="Hello Spring!"></property>

         </bean>

(3)编写代码使用spring获取对象

//读取配置文件

                   ApplicationContext context = new ClassPathXmlApplicationContext("applicationContext.xml");

                   //获取bean标签表示的对象

                   HelloBean helloBean = (HelloBean) context.getBean("helloBean");

                   System.out.println(helloBean.getHello());

b.AOP:面向切面编程

 

 

 

 

相关文章: