enter image description here This is my project
请检查我的配置文件和映射文件,即使配置文件位于同一文件夹中,配置文件也无法找到映射资源。
我的hibernate配置文件
[>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"> <hibernate-configuration> <session-factory> <!-- Related to the connection START --> <property name="connection.driver_class">oracle.jdbc.driver.OracleDriver </property> <property name="connection.url">jdbc:oracle:thin:@localhost:3306:XE</property> <property name="connection.user">root</property> <property name="connection.password">maherukh</property> <!-- Related to the connection END --> <!-- Related to hibernate properties START --> <property name="show_sql">true </property> <property name="dialet">org.hibernate.dialect.OracleDialect </property> <property name="hbm2ddl.auto">update </property> <!-- Related to hibernate properties END --> <!-- Related to mapping START --> <mapping resource="Product.hbm.xml" /> <!-- Related to the mapping END --> </session-factory> </hibernate-configuration>][2]
我的hibernate制图文件
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> <hibernate-mapping> <class name="Product" table="PRODUCTS"> <id name="productId" column="pid" > <generator class="assigned" /> </id> <property name="proName" column="pname" /> <property name="price"/> </class> </hibernate-mapping>
答案 0 :(得分:-1)
您是否尝试过:&lt; mapping resource =“str / Product.hbm.xml”/&gt; 默认情况下,您的类路径是src,因此hibernate可能会在src中搜索您的映射文件