报“org.hibernate.MappingException: Could not read mappings from resource:”
hibernate.cfg.xml
--------------------------------------
<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<!-- Database connection settings -->
<property name="connection.driver_class">com.microsoft.jdbc.sqlserver.SQLServerDriver</property>
<property name="connection.url">jdbc:microsoft:sqlserver://127.0.0.1:1433;DatabaseName=jsptest;SelectMethod=cursor</property>
<property name="connection.username">sa</property>
<property name="connection.password">mypassword</property>
<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">1</property>
<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.SQLServerDialect</property>
<mapping resource="com/jsftest/model/businessobj/User.hbm.xml"/>
</session-factory>
</hibernate-configuration>
User.hbm.xml的内容如下:
<?xml version="1.0" encoding='utf-8'?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping package="com.jsftest.model.businessobject">
<class name="User"
table="user">
<id name="userName" column="userName"
unsaved-value="null">
<generator class="assigned"/>
</id>
<property name="password"
column="password"/>
</class>
</hibernate-mapping>
一运行就会出现如标题所示错误,这是为什么?
------解决方法--------------------------------------------------------
你把hbm文件放在这个文件夹结构里了吗?
com/jsftest/model/businessobj/User.hbm.xml
------解决方法--------------------------------------------------------
<mapping resource="com/jsftest/model/businessobj/User.hbm.xml"/>
第一个的
<hibernate-mapping package="com.jsftest.model.businessobject">
第二个的
不一样
肯定错