升级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.jarspring-webmvc-2.5.6.jarspring-test-2.5.6.jar
// aop的依赖aopalliance-1.0.jar// 增加spring3.1.2相关jarorg.springframework.beans-3.1.2.RELEASE.jarorg.springframework.context-3.1.2.RELEASE.jarorg.springframework.context.support-3.1.2.RELEASE.jarorg.springframework.core-3.1.2.RELEASE.jarorg.springframework.jdbc-3.1.2.RELEASE.jarorg.springframework.orm-3.1.2.RELEASE.jarorg.springframework.test-3.1.2.RELEASE.jarorg.springframework.transaction-3.1.2.RELEASE.jarorg.springframework.web-3.1.2.RELEASE.jarorg.springframework.web.servlet-3.1.2.RELEASE.jar
<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>
<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">
<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">
public class AAASDao extends SimpleJdbcDaoSupport { ...(略)}
public class AAASDao extends JdbcDaoSupport { ...(略)}
@RunWith(SpringJUnit4ClassRunner.class)@ContextConfiguration(locations = { "classpath:applicationContext.xml" })public class BaseTest extends AbstractJUnit4SpringContextTests { ...(略)}