图文教你整合最新版本搭建SSH框架之一:spring(非常详细)
2017-04-08 15:14
686 查看
SSH框架搭建
由于配置过程会使用到很多图片,如果都写在一篇的话,会显得过于冗长,因此搭建过程分为几个博文来写,最终的框架项目我放到整合的那一篇博文中配置spring
1.首先找到官网,百度输入spring下载搜索即可2.打开进入网站,找到下图的这个链接
3.点击后进入在网页中搜索Zip Files,找到如图链接
4.进入后即可看到各个版本的spring框架包,选择最新版本
5.选择 dist.zip结尾的文件
6.解压后得到的文件
7.下载完文件包,下面开始进行框架搭建,我个人用的是Eclipse Java EE版本,打开IDE,创建一个Dynamic Web Project(项目名叫SSHDemo),Tomcat根据版本设置,我用的是Tomcat7.0
8.在WEB-INF->lib下新建文件夹spring-framework-4.3.7,从我们刚才的文件包的libs目录下找到如下的jar加入我们Eclipse项目的lib目录下的spring文件夹中
9.然后还需要将这些jar包配置到我们的项目下,具体步骤是右键项目,选择Build Path->Configure Build Path…
10.然后点击Add Jar选择lib目录下的jar加入,最后Apply即可
11.接下来我们在src建立一个包pers.zzf.test,下面建一个SpringTest.java,用来测试Spring框架
package pers.zzf.test; import org.springframework.context.ApplicationContext; import org.springframework.context.support.FileSystemXmlApplicationContext; public class SpringTest { private String name; public String getName() { return name; } public void setName(String name) { this.name = name; } public static void main(String... args){ ApplicationContext context = new FileSystemXmlApplicationContext("src\\applicationContext.xml"); SpringTest test = (SpringTest) context.getBean("springTest"); System.out.println(test.getName()); } }
12.由于Spring框架还需要一个配置文件applicationContext.xml,这个模板我们可以到我们之前下载的文件包里面找到spring-framework-reference.pdf这个pdf文件
13.打开这个pdf文件后,搜索XML-based configuration metadata,找到如图的地方可以看到一个配置文件模板
14.在src建一个applicationContext.xml文件,将我们刚才找到的模板复制过去,并进行相应位置的修改
原始模板:
<?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 http://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>
修改后的模板:
<?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 http://www.springframework.org/schema/beans/spring-beans.xsd"> <bean id="springTest" class="pers.zzf.test.SpringTest"> <!-- collaborators and configuration for this bean go here --> <property name="name"> <value>ZZF</value> </property> </bean> <!-- more bean definitions go here --> </beans>
15.配置到这一步项目结构如下
15.现在可以运行SpringTest.java可以看到控制台输出ZZF
相关文章推荐
- 图文教你整合最新版本搭建SSH框架之三:struts2(非常详细)
- 图文教你整合最新版本搭建SSH框架之二:hibernate(非常详细)
- Spring (MVC) 4.3.7 Mybatis3.4.2 (最新版本)整合详细介绍
- Spring (MVC) 4.3.7 Mybatis3.4.2 (最新版本)整合详细介绍
- SSH框架搭建和整合(struts2、spring4、hibernate5)
- SSM系列1:简易详细的(Spring +Springmvc+Mybatis)框架整合搭建
- android 最新 NDK r8 在window下开发环境搭建 安装配置与使用 详细图文讲解,完整实际配置过程记录
- SSH框架搭建和整合(struts2、spring4、hibernate5)
- mybatis学习笔记(六) -- maven+spring+mybatis从零开始搭建整合详细过程(下)
- android 最新 NDK r8 在window下开发环境搭建 安装配置与使用 详细图文讲解,完整实际配置过程记录(原创)
- 最新的SSH框架(Spring4.3.3 +Struts2.5.2+Hibernate5.2.3)搭建
- SSH框架搭建和整合(struts2、spring4、hibernate5)
- SSH框架搭建和整合(struts2、spring4、hibernate5)
- SSH框架搭建Struts2.06+spring2.5+hibernate3.2整合实例代码教程步骤
- 最新版本Spring、Hibernate、Struts框架整合
- SSM框架搭建详细过程,springmvc、spring、mybatis整合
- 最新版SSH框架简单整合(Struts 2.3.15.2 + Spring 4.0.0 + Hibernate 4.2.6)与整合手记
- CDH版本大数据集群下搭建的Hue详细启动步骤(图文详解)
- Spring3整合Hibernate4 Annotation详细图文教程