`
- 浏览:
485277 次
- 性别:
- 来自:
北京
-
spring3 之 升格Spring从2.5.6至3.1.2过程
http://www.myexception.cn/software-architecture-design/963643.html
升级Spring从2.5.6至3.1.2过程实录
1、引言
项目使用的是Spring MVC + Spring + iBatis框架,Spring和Spring MVC的版本都是2.5.6,但项目功能开发上需要支持REST功能,Spring MVC 2.5.6对REST的支持不够,于是决定升级Spring及Spring MVC至最新版本3.1.2
2、准备
至SpringSource的官方网站下载最新的Spring版本(当前最新release版本为3.1.2),地址
http://www.springsource.org/download/community
3、更新过程
(1)更新Spring和Spring MVC相关的jar
删除原有的Spring依赖,项目原有的依赖为
spring-2.5.6.jar
spring-webmvc-2.5.6.jar
spring-test-2.5.6.jar
增加项目新版的Spring依赖文件
// aop的依赖
aopalliance-1.0.jar
// 增加spring3.1.2相关jar
org.springframework.beans-3.1.2.RELEASE.jar
org.springframework.context-3.1.2.RELEASE.jar
org.springframework.context.support-3.1.2.RELEASE.jar
org.springframework.core-3.1.2.RELEASE.jar
org.springframework.jdbc-3.1.2.RELEASE.jar
org.springframework.orm-3.1.2.RELEASE.jar
org.springframework.test-3.1.2.RELEASE.jar
org.springframework.transaction-3.1.2.RELEASE.jar
org.springframework.web-3.1.2.RELEASE.jar
org.springframework.web.servlet-3.1.2.RELEASE.jar
(2)更新web.xml中的Spring启动配置
原内容:
<servlet>
<servlet-name>SpringContextServlet</servlet-name>
<servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
修改为:
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
(3)更新Spring的所有XML配置文件的头部
原有applicationContext*.xml的头部
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">
修改为:
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
即:将applicationContext*.xml头部中的所有的2.5修改为3.0
(4)更新Spring MVC的所有XML配置文件的头部
原有servlet*.xml的头部
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd">
修改为:
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
即:将servlet*.xml头部中的所有的2.5修改为3.0
(5)修改所有的继承SimpleJdbcDaoSupport的文件
原代码:
public class AAASDao extends SimpleJdbcDaoSupport {
...(略)
}
修改为:
public class AAASDao extends JdbcDaoSupport {
...(略)
}
注:SimpleJdbcDaoSupport 及SimpleJdbcTemplate,已经在3.1.2版本中被废弃原因是JdbcDaoSupport 或NamedParameterJdbcDaoSupport已经提供了其所有功能,可替换为JdbcDaoSupport 或NamedParameterJdbcDaoSupport(派生于JdbcDaoSupport)
参考地址http://kimsoftware.iteye.com/blog/1554218
(6)另外,Spring MVC基于注解的Junit测试的注解
原内容
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "classpath:applicationContext.xml" })
public class BaseTest extends AbstractJUnit4SpringContextTests {
...(略)
}
@RunWith(SpringJUnit4ClassRunner.class)会报错,网上找了一下,不知如何处理,后来由于该部分的代码,项目中已经没有用到了,故将其删掉了,有兴趣的童靴可以再找找修正方法
4、运行&测试
经过上面的处理过程,项目已不再提示错误,运行web项目后,经测试项目的功能基本没有问题,升级完成。
5、总结
项目升级后基本的测试是没有问题的,但不知道有没有其它未知的问题,有待后续的进一步观察和测试
分享到:
Global site tag (gtag.js) - Google Analytics
相关推荐
Spring 2.5.6:spring.jar、spring-webmvc.jar、commons-logging.jar、cglib-nodep-2.1_3.jar Hibernate 3.6.8:hibernate3.jar、hibernate-jpa-2.0-api-1.0.1.Final.jar、antlr-2.7.6.jar、commons-...
org.springframework.spring-context-2.5.6
org.springframework.web.servlet-2.5.6.SEC01.jar
spring 2.5.6 官方包 spring-framework-2.5.6.SEC02.zip spring-framework-2.5.6.SEC02.zip spring-framework-2.5.6.SEC02.zip
spring-context-support-2.5.6.jar
spring2.5.6.zip包括spring2.5.6所有jar包为
spring2.5.6官方jar包 spring2.5.6官方jar包 spring2.5.6官方jar包 spring2.5.6官方jar包 spring2.5.6官方jar包 spring2.5.6官方jar包 spring2.5.6官方jar包
赠送jar包:spring-boot-autoconfigure-2.5.6.jar; 赠送原API文档:spring-boot-autoconfigure-2.5.6-javadoc.jar; 赠送源代码:spring-boot-autoconfigure-2.5.6-sources.jar; 赠送Maven依赖信息文件:spring-...
The Spring Framework - Reference Documentation。 spring2.5.6的references,由官方的references转化后得来。
spring-webmvc-struts-2.5.6-sources
spring-2.5.6 jar包,spring-2.5.6源码包,spring-2.5.6文档
spring2.5.6jar包sprinspring2.5.6jar包g2.5.6jar包spring2.5.6jar包
Spring2.5.6学习笔记-最新Spring2.5.6学习笔记-最新Spring2.5.6学习笔记-Spring2.5.6学习笔记-最新Spring2.5.6学习笔记-最新Spring2.5.6学习笔记-最新最新
spring2.5.6相关依赖jar包,包含完整的依赖包
Spring2.5.6 帮助文档 API
在本文中,我将试图解释Spring能完成什么,和我怎么会认为它能帮助你开发J2EE应用程序。 另一framework? 你可能正在想“不过是另外一个的framework”。当已经有许多开放源代码(和专有) J2EE framework时,为什么你...
spring framework 2.5.6的源码. Version 2.5.6 is the sixth update release in the Spring 2.5 series. It contains many bug fixes, along with upgrades and minor enhancements throughout the framework