Spring MVC和Hibernate配置 [英] Spring MVC and Hibernate configurations
问题描述
我有以下配置文件
请点击此链接配置文件:配置文件
我收到以下错误:
org.springframework.beans.factory.CannotLoadBeanClassException:找不到类[org.springframework。 org.hibernate4.annotation.AnnotationSessionFactoryBean]用于在ServletContext资源中定义名为'sessionFactory'的bean [/WEB-INF/hibernateDataAccessContext.xml];嵌套异常是java.lang.ClassNotFoundException:org.springframework.orm.hibernate4.annotation.AnnotationSessionFactoryBean
根本原因:
引发:java.lang.ClassNotFoundException:org.springframework.orm.hibernate4.annotation.AnnotationSessionFactoryBean
是的,我的班级路径中包含spring-aop jar。我将不胜感激任何帮助。
编辑:
我的搜寻没有成果。谢谢。这个问题已解决,但我最初的意图是解决以下错误:
org.springframework.beans.factory.BeanCreationException :在ServletContext资源[/WEB-INF/hibernateDataAccessContext.xml]中定义的名称'org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0'中创建Bean的错误:Bean的初始化失败;嵌套异常是java.lang.NoClassDefFoundError:org / aopalliance / aop / Advice
这就是为什么我提到我已经有spring- aop in the class path。
org.springframework.orm.hibernate4.annotation.AnnotationSessionFactoryBean code>不存在。
请参阅 Hibernate Documentation 。
从question 。
我认为你应该使用
org.springframework.orm.hibernate4.LocalSessionFactoryBean而不是
org.springframework。 orm.hibernate3.annotation.AnnotationSessionFactoryBean
从LocalSessionFactoryBean javadoc:
注意: LocalSessionFactoryBean的这种变体需要Hibernate 4.0或更高版本。它的作用类似于
orm.hibernate3包中的同名命名类。但实际上,它更接近
AnnotationSessionFactoryBean,因为它的核心目的是从注释扫描引导
SessionFactory。
>
I have been struggling with this problem for a few days now. I am building a spring mvc hibernate framework.
I have the following configuration file
Please follow this link for the config file : ConfigurationFile
I am receiving the following error:
org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.springframework.orm.hibernate4.annotation.AnnotationSessionFactoryBean] for bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/hibernateDataAccessContext.xml]; nested exception is java.lang.ClassNotFoundException: org.springframework.orm.hibernate4.annotation.AnnotationSessionFactoryBean
Root cause:
Caused by: java.lang.ClassNotFoundException: org.springframework.orm.hibernate4.annotation.AnnotationSessionFactoryBean
Yes, I do have the spring-aop jar included in the class path. I would appreciate any help. My searches have not been fruitful.
Edit:
Thank you. That issue is solved, however my initial intention of this question was to solve the following error:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor#0' defined in ServletContext resource [/WEB-INF/hibernateDataAccessContext.xml]: Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/aopalliance/aop/Advice
This is why I mentioned that I already have spring-aop in the class path.
org.springframework.orm.hibernate4.annotation.AnnotationSessionFactoryBean
does not exist.
See the Hibernate Documentation.
From this question.
I think you should use org.springframework.orm.hibernate4.LocalSessionFactoryBean instead of org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean
From 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.
这篇关于Spring MVC和Hibernate配置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!