hibernate中 org.hibernate.MappingException

hibernate中的 org.hibernate.MappingException 解决办法:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Invocation of init method failed; nested exception is org.hibernate.MappingException: An AnnotationConfiguration instance is required to use 

Caused by: org.hibernate.MappingException: An AnnotationConfiguration instance is required to use 

把配置文件中:applicationContext.xml


        
            classpath:hibernate.cfg.xml
        
    

改成:


        
            classpath:hibernate.cfg.xml
        
    

---------------------------------------

因为,hibernate中注解你用的是import javax.persistence.Entity;

so。。。。


还要注意的是:Configuration只支持xml配置,不支持注解。如果数据库的表用注解写的,同时又用了Configuration,它也会报上面这个错。

解决办法:AnnotationConfiguration扩展了Configuration类,同时支持xml配置和注解方式。

你可能感兴趣的:(Java,java,hibernate,exception)