2011-08-19 35 views
0

我有一個映射資源的問題在我的hibernate.cfg.xml - 我得到Hibernate映射的資源必須跟任一屬性規格,「>」或「/>」「。

Element type "mapping-resource" must be followed by either attribute specifications, ">" or "/>".' 

我的hibernate.cfg.xml看起來像

<?xml version='1.0' encoding='utf-8'?> 
<!DOCTYPE hibernate-configuration PUBLIC 
    "-//Hibernate/Hibernate Configuration DTD//EN" 
    "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> 
<hibernate-configuration> 

    <session-factory> 
     <property name="datasourceName">java:jboss/datasources/MySqlDS</property> 
     <property name="dialect">org.hibernate.dialect.MySQLDialect</property> 
     <mapping-resource="com/mycompany/myapp/common/businessobjects/User.hbm.xml"/> 
     <mapping-resource="com/mycompany/myapp/common/businessobjects/Company.hbm.xml"/> 
     <mapping- resource="com/mycompany/myapp/common/businessobjects/ServerSettings.hbm.xml"/> 
     <mapping-resource="com/mycompany/myapp/common/businessobjects/Station.hbm.xml"/> 
    </session-factory> 
</hibernate-configuration> 

不知道是什麼問題?語法似乎正確?我在我的基礎測繪資源的東西上的信息在這裏

http://docs.jboss.org/hibernate/core/3.3/reference/en/html/session-configuration.html

+0

想必當你在複製的XML映射'-____ resource'大空白髮生了什麼? –

回答

2

你誤解了規範(見3.7)。它需要看起來像

<mapping resource="com/mycompany/myapp/common/businessobjects/User.hbm.xml"/> 

你有一個 - (減號)在那裏它應該是一個空間。 XML標記是「映射」的屬性是「資源」

1

它的壞的XML語法。你不能寫<name="something"/>;它必須是<name attrname="something"/>。 XML解析器是抱怨,因爲它沒有找到="之前的屬性名稱。

您鏈接到文件沒有提及mapping-resource可言,因此很難說什麼正確的語法使用會。不過,您可以試試

<mapping-resource>com/mycompany/myapp/common/businessobjects/User.hbm.xml</mapping-resource> 

它有一定的工作機會。 (至少它是格式良好的XML,但它是否是您的工具期望的特定結構,我不能說)。

相關問題