日期:2014-05-19  浏览次数:20679 次

hibernate 错误,小白求救!!
我是按照马士兵视频一步一步来的,我所用的版本是hibernate3.6,他用的是3.3.2,然后我在运行时就出现问题了,错误如下:
Exception in thread "main" java.lang.NoClassDefFoundError: com/lv/hibernate/model/student (wrong name: com/lv/hibernate/model/Student)
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:169)
at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:192)
at org.hibernate.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:228)
at org.hibernate.mapping.SimpleValue.setTypeUsingReflection(SimpleValue.java:316)
at org.hibernate.cfg.HbmBinder.bindSimpleId(HbmBinder.java:451)
at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder.java:384)
at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:323)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:174)
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processHbmXml(Configuration.java:3948)
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processHbmXmlQueue(Configuration.java:3940)
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3928)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1368)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1826)
at StudentTest.main(StudentTest.java:15)
配置文件之一:Student.hbm.xml
XML code
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
        "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
        "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd">

<hibernate-mapping package="com.lv.hibernate.model">
    <class name="student">
        <id name="id"></id>
        <property name="sname"></property>
        <property name="age"></property>
    </class>
</hibernate-mapping>


------解决方案--------------------
Student.hbm.xml配置文件中class标签的name属性应该是Student,你写成student了
------解决方案--------------------
student Student 很明显。。,
------解决方案--------------------
探讨
Exception in thread "main" java.lang.NoClassDefFoundError: com/lv/hibernate/model/student (wrong name: com/lv/hibernate/model/Student……

------解决方案--------------------
<hibernate-mapping package="com.lv.hibernate.model">
<class name="student">
<id name="id"></id>
<property name="sname">