?以下是兩個(gè)hibernate映射文件:Activity:<?xml?version="1.0"?encoding="gb2312"?>
<!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.ywt.domain">??
????<class?name="Activity"?table="activity"?lazy="true">??
????????<!--?id元素定義持久化類的標(biāo)識(shí)屬性?-->??
????????<id?name="id">
????????????<!--?指定主鍵生成策略?-->??
????????????<generator?class="native"?/>??
????????</id>??
????????<!--?property元素定義常規(guī)屬性?-->??
????????<property?name="name"?not-null="true"/>??
????????<property?name="time"?not-null="true"/>??
????????<property?name="imageurl"?not-null="true"/>??
????????<property?name="hostone"?not-null="true"/>??
????????<property?name="hosttwo"?not-null="true"/>??
????????<property?name="introduce"?not-null="true"/>??
????????<property?name="problem"?/>??
????????<property?name="award"?/>??
????????<property?name="schedule"?/>??
????????<property?name="number"?/>??
????????<property?name="status"?not-null="true"/>??
????????<set?name="studentSet"?table="activity_student"?inverse="true">
???????? <key>
???????? <column?name="A_ID"></column>
???????? </key>
???????? <many-to-many?class="Student"?column="S_ID"?></many-to-many>
????????</set>??
????</class>??
</hibernate-mapping>Student:<?xml?version="1.0"?encoding="gb2312"?>
<!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.ywt.domain">??
????<!--?每個(gè)class元素對(duì)應(yīng)一個(gè)持久化對(duì)象?lazy="true"?代表加載延遲?對(duì)象A對(duì)對(duì)象B引用才會(huì)用到-->??
????<class?name="Student"?table="student"?lazy="true">??
????????<!--?id元素定義持久化類的標(biāo)識(shí)屬性?-->??
????????<id?name="id">
????????????<!--?指定主鍵生成策略?-->??
????????????<generator?class="native"?/>??
????????</id>??
????????<!--?property元素定義常規(guī)屬性?-->??
????????<property?name="username"?not-null="true"/>??
????????<property?name="password"?not-null="true"/>??
????????<property?name="name"?not-null="true"/>??
????????<property?name="sex"?not-null="true"/>??
????????<property?name="major"?not-null="true"/>??
????????<property?name="academy"?not-null="true"/>??
????????<property?name="tel"?/>??
????????<property?name="coin"/>??
????????<property?name="activities"?/>??
????????<property?name="honor"?/>?
????????<set?name="activitySet"?table="activity_student">
???????? <key>
???????? <column?name="S_ID"></column>
???????? </key>
???????? <many-to-many?class="Activity"?column="A_ID"></many-to-many>
????????</set>??
????</class>??
</hibernate-mapping>所出現(xiàn)的問題是:只要Activity映射文件中一加set集合就報(bào)如下錯(cuò)誤(Student映射文件中加set不報(bào)錯(cuò),已確認(rèn)各屬性書寫沒錯(cuò)誤):嚴(yán)重: Servlet.service() for servlet [mvc] in context with path [/dxshdw] threw exception [Handler processing failed; nested exception is java.lang.NoClassDefFoundError: Could not initialize class com.ywt.util.HibernateUtil] with root causejava.lang.NoClassDefFoundError: Could not initialize class com.ywt.util.HibernateUtil其中HibernateUtil是獲取session工廠的類
3 回答

葉為正啊
TA貢獻(xiàn)2條經(jīng)驗(yàn) 獲得超0個(gè)贊
Could not initialize class com.ywt.util.HibernateUtil] 這個(gè)類有問題吧

夢(mèng)影劍魂
TA貢獻(xiàn)66條經(jīng)驗(yàn) 獲得超21個(gè)贊
class com.ywt.util.HibernateUtil這個(gè)工具類就找不見,看是servlet中忘了導(dǎo)入還是其他
添加回答
舉報(bào)
0/150
提交
取消