H,我想在我的网络应用程序中升级Spring库。由于我也在使用Hibernate,我想知道是否有一种方法可以找到哪个版本的Hibernate与特定版本的Spring兼容。
我已经搜索了谷歌并阅读了类似的SO帖子,但我想知道是否有办法比较不同版本的库/框架。
我目前的设置:
Spring V2.5
Hibernate : 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)
答案 0 :(得分:26)
您可以在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。
当然你可以尝试使用不同版本的Hibernate使用Spring,但是POM的版本不太可能给你一些问题。
答案 1 :(得分:4)
如果您无法在Windows中执行grep命令,请导航到.m2\repository\org\springframework\spring-orm\4.2.5.RELEASE\spring-orm-4.2.5.RELEASE.pom
文件位置。在编辑器中打开pom文件并搜索单词&#34; hibernate&#34;你可以找到你的spring版本的依赖项。 [grep命令也使用相同的方法]
答案 2 :(得分:0)