Hibernate + Spring版本兼容性
H,我想在Web应用程序中升级Spring库。由于我也使用Hibernate,所以我想知道是否可以找到一种版本的Hibernate与特定版本的Spring兼容。
我已经搜索过Google并阅读过类似的SO文章,但我想知道是否有一种方法可以比较不同版本的库/框架。
我当前的设置:
Spring V2.5Hibernate : org.hibernate.hibernate 3.2.6.ga
org.hibernate.hibernate-annotations 3.3.1.ga
我的存储库中提供了最新版本的Hibernate,3.5.4-FINAL
并且3.5.6-FINAL
适用于上述工件
在Spring 2.5将Hibernate从3.2升级到3.5.4后,我得到了这个错误(未更改)
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0' defined in class path resource [applicationContext-hibernate.xml]: Initialization of bean failed;
nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory'
defined in class path resource [applicationContext-hibernate.xml]: Invocation of init method failed; nested exception is java.lang.IncompatibleClassChangeError:
Implementing class
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:480)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory$1.run(AbstractAutowireCapableBeanFactory.java:409)
at java.security.AccessController.doPrivileged(Native Method)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:380)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:264)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:221)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:261)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:185)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:164)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:881)
at org.springframework.context.support.AbstractApplicationContext.registerBeanPostProcessors(AbstractApplicationContext.java:597)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:366)
at org.springframework.web.context.ContextLoader.createWebApplicationContext(ContextLoader.java:255)
at org.springframework.web.context.ContextLoader.initWebApplicationContext(ContextLoader.java:199)
at org.springframework.web.context.ContextLoaderListener.contextInitialized(ContextLoaderListener.java:45)
at org.apache.catalina.core.StandardContext.listenerStart(StandardContext.java:4206)
at org.apache.catalina.core.StandardContext.start(StandardContext.java:4705)
at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:799)
at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:779)
at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:601)
at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:1079)
at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:1002)
at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:506)
at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1317)
at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:142)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1065)
at org.apache.catalina.core.StandardHost.start(StandardHost.java:840)
at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1057)
at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:463)
at org.apache.catalina.core.StandardService.start(StandardService.java:525)
at org.apache.catalina.core.StandardServer.start(StandardServer.java:754)
at org.apache.catalina.startup.Catalina.start(Catalina.java:595)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:289)
at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:414)
回答:
您可以在spring-orm
Maven POM中进行检查。
例如,要检查Spring 3.2.3.RELEASE使用的Hibernate版本,可以发出以下shell命令:
grep -A 1 hibernate- ~/.m2/repository/org/springframework/spring-orm/3.2.3.RELEASE/spring-orm-3.2.3.RELEASE.pom
上面的命令将导致以下输出:
<artifactId>hibernate-annotations</artifactId> <version>3.4.0.GA</version>
--
<artifactId>hibernate-core</artifactId>
<version>4.1.9.Final</version>
--
<artifactId>hibernate-core</artifactId>
<version>3.3.2.GA</version>
--
<artifactId>hibernate-entitymanager</artifactId>
<version>4.1.9.Final</version>
--
<artifactId>hibernate-entitymanager</artifactId>
<version>3.4.0.GA</version>
从上面的输出中我们可以推断出Spring 3.2.3.RELEASE支持Hibernate 4.1.9.Final和3.3.2.GA。
当然,您可以尝试将Spring与其他版本的Hibernate一起使用,但是POM的版本不太可能给您带来一些问题。
以上是 Hibernate + Spring版本兼容性 的全部内容, 来源链接: utcz.com/qa/432040.html