下面长话短说,spring框架是用来管理我们的对象的一个主流框架,他通过IOC(对象的控制反转以及DI注入是属性和方法)来管理的。

关于spring框架全称也是(Spring Framework并且他的创始人还是一个音乐博士)xml配置的搭建:

首先得去官网下载spring框架,官网地址是:https://spring.io/

进去页面点击Spring Framework

xml配置restemplate连接池 xml spring_xml配置


进去再点击标题右边的小猫图标,这是由于spring是交给GitHub管理的。

xml配置restemplate连接池 xml spring_java_02


xml配置restemplate连接池 xml spring_xml配置restemplate连接池_03


xml配置restemplate连接池 xml spring_xml配置_04


xml配置restemplate连接池 xml spring_spring_05


xml配置restemplate连接池 xml spring_xml配置restemplate连接池_06


xml配置restemplate连接池 xml spring_java_07


xml配置restemplate连接池 xml spring_spring_08


之后进去选择下载好自己对应的压缩版本就OK了。

加压之后就有三个对应的文件夹,其中libs装的就是我要 工作的jar包。

xml配置restemplate连接池 xml spring_xml配置_09


但工作前我们还要先看一下他的具体操作文档

xml配置restemplate连接池 xml spring_spring_10


xml配置restemplate连接池 xml spring_spring_11


xml配置restemplate连接池 xml spring_spring框架_12


里面介绍了core和一些web项目怎么使用spring,具体的就自己去探索了。

xml配置restemplate连接池 xml spring_xml配置_13


我们点进core就能看到spring的具体使用过程

xml配置restemplate连接池 xml spring_spring_14


我们要在自己的项目中创建一个自己的xml配置文件名字可以随意取但最好取applicationContext.xml统一一下然后将index.html文档中的核心配置粘贴一下,并且将spring中的libs文件的包导进道工程里(这里这导入了所需要的jar包,也可以全部导入)

xml配置restemplate连接池 xml spring_spring_15


xml配置restemplate连接池 xml spring_xml配置restemplate连接池_16


这里就用Studnet对象来举个栗子,我们要在beans标签中插入bean标签让spring来管理我们的bean对象。

之后就要创建一个主类如下代码

xml配置restemplate连接池 xml spring_spring_17


xml配置restemplate连接池 xml spring_spring_18

到这里xml配置好的一个spring框架的基本使用就完成了。