整合SSH三大框架用注解时报An AnnotationConfiguration instance is required to use

如下异常:

Caused by: org.hibernate.MappingException: AnAnnotationConfiguration instance is required to use<mappingclass="com.zzh.ssh.entity.Account"/>
 atorg.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1648)
 atorg.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1603)
 atorg.hibernate.cfg.Configuration.doConfigure(Configuration.java:1582)
 atorg.hibernate.cfg.Configuration.doConfigure(Configuration.java:1556)
 atorg.hibernate.cfg.Configuration.configure(Configuration.java:1491)
 atorg.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:601)
 atorg.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
 atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369)
 atorg.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)
 ... 39 more

解决 方案:

将SPRING 的配置文件 装配 SESSIONFACTORY的地方的CLASS

org.springframework.orm.hibernate3.LocalSessionFactoryBean

改成

org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean

检查Spring中sessionFactory中是否引进了hibernate文件

<bean id="sessionFactory"

class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">

<property name="configLocation"

value="classpath:hibernate.cfg.xml">

</property>

</bean>

你可能感兴趣的:(整合SSH三大框架用注解时报An AnnotationConfiguration instance is required to use)