SSH框架升级
Spring2.5.6+Hibernate3.0.5升级到Spring3.0.5+Hibernate3.3
1、引言
项目使用的是Struts1 + Spring2.5.6 + Hibernate3.0.5框架,但项目需要开发Flex客户端, Spring 2.5.6不支持与Flex集成,于是决定升级Spring至 3.0.5版本 ,升级Spring的过程中,发现Spring3.0.5版本与Hibernate3.0.5版本不兼容,于是不得不也把Hibernate升级到更高的3.3版本。
2、准备
下载release版本的Spring-3.0.5.jar和Hibernate-3.3.jar包。
http://search.maven.org/
一个强大的jar包下载网站,这里几乎可以找到你所需要的所有jar包及源码
3、更新过程
1) 更新Spring相关的jar
删除原有的Spring jar包,项目原有的jar包为
-
spring.jar spring-beans-2.5.6.jar spring-context-2.5.6.jar spring-context-support-2.5.6.jar spring-core-2.5.6.jar spring-jdbc-2.5.6.jar spring-tx-2.5.6.jar spring-web-2.5.6.jar spring-webmvc-2.5.6.jar
增加项目新版的Spring jar文件
-
org.springframework.aop-3.0.5.RELEASE.jar org.springframework.asm-3.0.5.RELEASE.jar org.springframework.beans-3.0.5.RELEASE.jar org.springframework.context-3.0.5.RELEASE.jar org.springframework.context.support-3.0.5.RELEASE.jar org.springframework.core-3.0.5.RELEASE.jar org.springframework.expression-3.0.5.RELEASE.jar org.springframework.jdbc-3.0.5.RELEASE.jar org.springframework.orm-3.0.5.RELEASE.jar org.springframework.transaction-3.0.5.RELEASE.jar org.springframework.web.servlet-3.0.5.RELEASE.jar org.springframework.web.struts-3.0.5.RELEASE.jar org.springframework.web-3.0.5.RELEASE.jar
另外需要增加三个Spring3.0依赖的jar
aop的依赖
-
aopalliance-1.0.jar
aspectjweaver-1.5.3.jar
和一个java字节码处理类库
-
javassist-3.9.0.GA.jar
2) 更新web.xml中的Spring启动配置
如果原来这样配置:
Xml代码
则修改为:
Xml代码
3) 更新Spring的所有XML配置文件的头部
原有applicationContext*.xml的头部
Xml代码
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/contexthttp://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/aop
>
修改为:
Xml代码
"1.0"encoding="UTF-8" >
xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx" 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
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/aop >
即:将applicationContext*.xml头部中的所有的2.5修改为3.0
4) 修改所有的继承SimpleJdbcDaoSuppo