zoukankan      html  css  js  c++  java
  • 整合SSH三大框架用注解时报An AnnotationConfiguration instance is required to use

    Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/classes/applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: An AnnotationConfiguration instance is required to use <mapping class="cn.net.xsoft.po.User"/>
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1338)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:473)
        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:222)
        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.beans.factory.support.BeanDefinitionValueResolver.resolveReference(BeanDefinitionValueResolver.java:269)
        ... 46 more
    Caused by: org.hibernate.MappingException: An AnnotationConfiguration instance is required to use <mapping class="cn.net.xsoft.po.User"/>
        at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1619)
        at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1574)
        at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1553)
        at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1527)
        at org.hibernate.cfg.Configuration.configure(Configuration.java:1462)
        at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessionFactory(LocalSessionFactoryBean.java:601)
        at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPropertiesSet(AbstractSessionFactoryBean.java:211)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1369)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1335)

        ... 56 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.annotation.AnnotationSessionFactoryBean">
    		<property name="configLocation" value="classpath:hibernate.cfg.xml">
    		</property>
    	</bean>



  • 相关阅读:
    java内部类
    重新回顾JSP
    vs 链接动态库 (不用放在可执行文件同一目录)
    c++ 文件夹读取文件
    为人处世
    Windows常用软件
    windows好用的软件
    冒泡排序,快速排序,归并排序
    最大公约数、最小公倍数、所有约数
    linux U盘 硬盘 unable to mount
  • 原文地址:https://www.cnblogs.com/dyllove98/p/3202705.html
Copyright © 2011-2022 走看看