hibernate出 an annotationconfiguration instance is required to use mapping
Exception in thread "main"
org.hibernate.MappingException: An AnnotationConfiguration instance is required to use <mapping class="myHibernate.Student"/>
at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:1597)
at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:1552)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1531)
at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:1505)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1425)
at org.hibernate.cfg.Configuration.configure(Configuration.java:1411)
at myHibernate.test.main(test.java:12)
Java code
Configuration configuration=new Configuration();
SessionFactory sf=configuration.configure().buildSessionFactory();
Session sess=sf.openSession();
我把
版本显示AnnotationConfiguration 类被废弃啦
XML code
<mapping class="myHibernate.Student"/>
</session-factory>
</hibernate-configuration
>
------解决方案--------------------
把Configuration改为AnnotationConfiguration就行了