图文教你整合最新版本搭建SSH框架之一:spring(非常详细)
来源:互联网 发布:死神虚圈篇配乐知乎 编辑:程序博客网 时间:2024/06/06 12:40
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/beanshttp://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/beanshttp://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框架之一:spring(非常详细)
- 图文教你整合最新版本搭建SSH框架之二:hibernate(非常详细)
- 图文教你整合最新版本搭建SSH框架之三:struts2(非常详细)
- SSH框架搭建详细图文教程
- SSH框架搭建详细图文教程
- SSH框架搭建 详细图文教程
- SSH框架搭建详细图文教程
- SSH框架搭建 详细图文教程
- 最新版本Spring、Hibernate、Struts框架整合
- 最新版本Spring、Hibernate、Struts框架整合
- 最新版本Spring、Hibernate、Struts框架整合
- 最新版本Spring、Hibernate、Struts框架整合
- 最新版本Spring、Hibernate、Struts框架整合
- 最新版本Spring、Hibernate、Struts框架整合
- 整合Struts2 Spring Hibernate,搭建SSH框架
- maven ssh最新版本整合
- SSH框架搭建整合
- SSH框架搭建过程---之Struts整合Spring框架(4)
- vncserver使用
- 硬盘的寻址方式
- Java Servlet理论篇
- JZOJ 4.8 2433——最短路上的统计【最短路】
- Xcode8+和iOS10.3 tableCell复用问题
- 图文教你整合最新版本搭建SSH框架之一:spring(非常详细)
- 第八届蓝桥杯第七题日期问题
- CSS遮罩——如何在CSS中使用遮罩
- 获取维基百科主页所有词条及链接
- 控件开发实战-自绘折线图
- JZOJsenior2433.2017.04.08【NOIP 普及组】模拟赛C组 T1最短路上的统计
- mysql远程连接错误1130的解决方法
- The method getContextPath() from the type HttpServletRequest refers to the missing type
- leetcode第六周解题报告