[英]spring migration 4 to 5; what is causing java.lang.ClassNotFoundException: org.springframework.orm.hibernate4.LocalSessionFactoryBean
I am migrating an old app from Spring 4 to 5. It builds fine with Maven, but when I start the app in jboss 7.1, I get this error:我正在将旧应用程序从 Spring 4 迁移到 5。它与 Maven 构建良好,但是当我在 jboss 中启动应用程序时,得到此错误:
java.lang.ClassNotFoundException: org.springframework.orm.hibernate4.LocalSessionFactoryBean
java.lang.ClassNotFoundException:org.springframework.orm.hibernate4.LocalSessionFactoryBean
Spring 5.3.20 Spring 5.3.20
Hibernate 5.3.28.Final Hibernate 5.3.28.Final
I have been following this guide, https://github.com/spring-projects/spring-framework/wiki/Upgrading-to-Spring-Framework-5.x我一直在关注本指南, https://github.com/spring-projects/spring-framework/wiki/Upgrading-to-Spring-Framework-5.x
This said Hibernate 5 is required, so I updated that in the pom to 5.3.28.Final这说 Hibernate 5 是必需的,所以我在 pom 中将其更新为 5.3.28.Final
Here is relevant snippet of spring-context.xml:这是 spring-context.xml 的相关片段:
<bean id="hibernateSessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="annotatedClasses">
<list>
<value>com.mycompany.bean.FooService</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.SQLServerDialect</prop>
<prop key="show_sql">true</prop>
</props>
</property>
</bean>
Running with Java 8.运行 Java 8。
You need to replace org.springframework.orm.hibernate4.LocalSessionFactoryBean
with org.springframework.orm.hibernate5.LocalSessionFactoryBean
.您需要将
org.springframework.orm.hibernate4.LocalSessionFactoryBean
替换为org.springframework.orm.hibernate5.LocalSessionFactoryBean
。
The relevant parts of the migration guide are:迁移指南的相关部分是:
Hibernate support has been upgraded to a Hibernate ORM 5.2+ baseline, with a focus on ORM 5.4.x.
Hibernate 支持已升级到 Hibernate ORM 5.2+ 基准,重点是 Z8B8A9A92C27C179FDD101。
This indicates that the minimum version of Hibernate is now Hibernate 5.2.这表明 Hibernate 现在的最低版本是 Hibernate 5.2。
and和
Packages
web.view.tiles2
andorm.hibernate3/hibernate4
dropped.包
web.view.tiles2
和orm.hibernate3/hibernate4
删除。
This indicates that the package your XML config is using ( org.springframework.orm.hibernate4
) no longer exists.这表明 package 您的 XML 配置正在使用(
org.springframework.orm.hibernate4
)不再存在。 Searching for LocalSessionFactoryBean
in the Spring Framework 5.3.22 apidoc shows org.springframework.orm.hibernate5.LocalSessionFactoryBean
.在Spring Framework 5.3.22 apidoc 中搜索 LocalSessionFactoryBean
LocalSessionFactoryBean
org.springframework.orm.hibernate5.LocalSessionFactoryBean
。 Its API seems compatible with your XML definition, so changing the class
property should be all that you need to change.它的 API 似乎与您的 XML 定义兼容,因此您只需更改
class
属性即可。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.