Unit測試報錯
cfg.xml配置文件
<property name="connection.username">root</property>
?? ? <property name="connection.password">root</property>
?? ? <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
?? ? <property name="connection.url">jdbc:mysql:///hibernate?useUnicode=true&characterEncoding=UTF-8</property>
?? ? <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
? ? ?
?? ? <property name="show_sql">true</property>
?? ? <property name="format_sql">true</property>
?? ? <property name="hbm2ddl.auto">create</property>
? ? ?
?? ? <mapping resource="Students.hbm.xml"/>
students.hbm.xml文件
?<class name="com.hibernate.Students" table="STUDENTS">
? ? ? ? <id name="id" type="int">
? ? ? ? ? ? <column name="ID" />
? ? ? ? ? ? <generator class="assigned" />
? ? ? ? </id>
? ? ? ? <property name="name" type="java.lang.String">
? ? ? ? ? ? <column name="NAME" />
? ? ? ? </property>
? ? ? ? <property name="sex" type="java.lang.String">
? ? ? ? ? ? <column name="SEX" />
? ? ? ? </property>
? ? ? ? <property name="birthdat" type="java.util.Date">
? ? ? ? ? ? <column name="BIRTHDAT" />
? ? ? ? </property>
? ? ? ? <property name="address" type="java.lang.String">
? ? ? ? ? ? <column name="ADDRESS" />
? ? ? ? </property>
來人幫忙看看原因
2016-06-24
試試添加包路徑,即<mappng resource="com.hibernate.Students.hbm.xml"/> 注意與你的類名包名相一致。