gpt4 book ai didi

java - Spring 3.1, hibernate 4,SessionFactory

转载 作者:IT老高 更新时间:2023-10-28 13:03:48 26 4
gpt4 key购买 nike

这是有效的:

<bean id="sessionFactory"  
class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
...

但升级到上述版本会破坏它。创建 SessionFactory 的正确方法是什么? Spring 3.1.ReleaseHibernate 4.0.0.FINAL 的 bean?

部署的错误是:

nested exception is java.lang.NoClassDefFoundError: Lorg/hibernate/cache/CacheProvider;


编辑
添加了我自己的答案,为我解决了这个问题。

最佳答案

我认为你应该使用 org.springframework.orm.hibernate4.LocalSessionFactoryBean 而不是org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean

来自 LocalSessionFactoryBean javadoc:

NOTE: This variant of LocalSessionFactoryBean requires Hibernate 4.0 or higher. It is similar in role to the same-named class in the orm.hibernate3 package. However, in practice, it is closer to AnnotationSessionFactoryBean since its core purpose is to bootstrap a SessionFactory from annotation scanning.

关于java - Spring 3.1, hibernate 4,SessionFactory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8565051/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com