Spring2.5.6+Hibernate3.0.5升级到Spring3.0.5+Hibernate3.3
来源:互联网 发布:动力it 编辑:程序博客网 时间:2024/05/21 17:52
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代码
- <servlet>
- <servlet-name>SpringContextServlet</servlet-name>
- <servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class>
- <load-on-startup>1</load-on-startup>
- </servlet>
则修改为:
Xml代码
- <listener>
- <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
- </listener>
3) 更新Spring的所有XML配置文件的头部
原有applicationContext*.xml的头部
Xml代码
<beans
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代码
<?xmlversion="1.0"encoding="UTF-8"?>
<beans
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) 修改所有的继承SimpleJdbcDaoSupport的文件
如果项目没有使用,这一步可以忽略。
原代码:
Java代码
- public class AbcDao extends SimpleJdbcDaoSupport {
- ...(略)
- }
修改为:
Java代码
- public class AbcDao extends JdbcDaoSupport {
- ...(略)
- }
注:SimpleJdbcDaoSupport 及SimpleJdbcTemplate,已经在3.1.2版本中被废弃原因是JdbcDaoSupport 或NamedParameterJdbcDaoSupport已经提供了其所有功能,可替换为JdbcDaoSupport 或NamedParameterJdbcDaoSupport(派生于JdbcDaoSupport)
参考地址http://kimsoftware.iteye.com/blog/1554218
5) 升级Hibernate Jar包
经过上面的改造,Spring的升级已经完成,此时可以运行web项目,会发现出现下面的异常:
java.lang.NoClassDefFoundError:org/hibernate/context/CurrentSessionContext
这是因为Hibernate-3.0.5的版本中不包含CurrentSessionContext这个类,因此我们需要把Hibernate升级到3.3(或其他版本,本人仅测试了3.3)
删除原来的jar:
1. hibernate3.jar
2. hibernate-annotations.jar
增加新版本的jar:
1. hibernate3.jar(包名虽相同,但其实版本不同)
2. hibernate-annotations.jar
3. hibernate-commons-annotations.jar
4. hibernate-entitymanager.jar
5. hibernate-jpa-2.0-api-1.0.1.Final.jar
4、运行&测试
经过上面的处理过程,项目已不再提示错误,运行web项目后,经测试项目的功能基本没有问题,升级完成。
5、总结
项目升级后基本的测试是没有问题的,但不知道有没有其它未知的问题,有待后续的进一步观察和测试
- Spring2.5.6+Hibernate3.0.5升级到Spring3.0.5+Hibernate3.3
- spring2.5.6与hibernate3.3整合
- struts-2.3、spring2.5.6、hibernate3.3整合
- 整合Spring3.0.5,Hibernate3.3,Struts2.3.8(中文OK)
- spring3+hibernate3
- Spring2.5+Hibernate3.3+Struts2
- Spring2.5.6整合hibernate3遇到的异常3
- spring3.0 MVC笔记3--从spring2.0转向spring3.0-集成Hibernate3及声明式事务
- struts2.1.8.1 + spring2.5.6 + Hibernate3.5.5
- struts2.1.8 + spring2.5.6 + hibernate3.3.2
- struts-1.3.8、spring2.5.6、hibernate3整合
- hibernate3与spring2.5.6整合Demo
- Struts2+Spring2.5+Hibernate3.3 整合总结
- Struts2+Spring2.5+Hibernate3.3整合开发
- Struts1.3 +hibernate3.2+Spring2.5整合
- JBPM4.3整合spring2.5+hibernate3.3.2
- Struts2+Spring2.5+Hibernate3.3 整合总结
- jbpm4整合struts2+spring2.5+hibernate3.3
- split
- 黑马程序员_java基础知识总结(1)面向对象基础总结
- 黑马程序员 Java基础 面向对象:内部类 异常 包 jar包
- man page
- poj2063-完全背包(逃不了tle的命运)
- Spring2.5.6+Hibernate3.0.5升级到Spring3.0.5+Hibernate3.3
- input文本框输入验证
- Mark系统架构
- Java中通过DOM方式提取出XML文档中的内容
- html基础知识点(2)
- 国家天地图API 创建点 覆盖物
- do{}while(0)和switch中嵌套while 整理
- WAMP安装教程
- redhat安装ftp服务