Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/eclipse/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Eclipse Hibernate映射可以';找不到资源_Eclipse_Hibernate_Maven_Mapping - Fatal编程技术网

Eclipse Hibernate映射可以';找不到资源

Eclipse Hibernate映射可以';找不到资源,eclipse,hibernate,maven,mapping,Eclipse,Hibernate,Maven,Mapping,我试图编译我的项目,但编译器不断地给出错误,他找不到我的资源文件,所以他无法编译 jul 23, 2013 1:29:24 PM org.hibernate.cfg.Configuration addResource INFO: HHH000221: Reading mappings from resource: src/main/resources/Movies.hbm.xml Initial SessionFactory creation failed.org.hibernate.M

我试图编译我的项目,但编译器不断地给出错误,他找不到我的资源文件,所以他无法编译

    jul 23, 2013 1:29:24 PM org.hibernate.cfg.Configuration addResource
INFO: HHH000221: Reading mappings from resource: src/main/resources/Movies.hbm.xml
Initial SessionFactory creation failed.org.hibernate.MappingNotFoundException: resource: src/main/resources/Movies.hbm.xml not found
Exception in thread "main" java.lang.ExceptionInInitializerError
    at com.hp.videotheek.HibernateUtil.<clinit>(HibernateUtil.java:17)
    at com.hp.videotheek.App.main(App.java:12)
Caused by: org.hibernate.MappingNotFoundException: resource: src/main/resources/Movies.hbm.xml not found
    at org.hibernate.cfg.Configuration.addResource(Configuration.java:738)
    at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:2167)
    at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:2139)
    at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2119)
    at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2072)
    at org.hibernate.cfg.Configuration.configure(Configuration.java:1987)
    at org.hibernate.cfg.Configuration.configure(Configuration.java:1966)
    at com.hp.videotheek.HibernateUtil.<clinit>(HibernateUtil.java:13)
    ... 1 more
2013年7月23日下午1:29:24 org.hibernate.cfg.Configuration addResource
信息:hh000221:正在从以下资源读取映射:src/main/resources/Movies.hbm.xml
初始SessionFactory创建失败。org.hibernate.MappingNotFoundException:资源:src/main/resources/Movies.hbm.xml未找到
线程“main”java.lang.ExceptionInInitializeError中出现异常
在com.hp.videotheek.HibernateUtil.(HibernateUtil.java:17)
位于com.hp.videotheek.App.main(App.java:12)
原因:org.hibernate.MappingNotFoundException:resource:src/main/resources/Movies.hbm.xml未找到
位于org.hibernate.cfg.Configuration.addResource(Configuration.java:738)
位于org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:2167)
位于org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:2139)
位于org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2119)
位于org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2072)
位于org.hibernate.cfg.Configuration.configure(Configuration.java:1987)
位于org.hibernate.cfg.Configuration.configure(Configuration.java:1966)
在com.hp.videotheek.HibernateUtil.(HibernateUtil.java:13)
... 还有一个
hibernate.cfg.xml文件,在这里他找不到映射资源,但它位于正确的位置

<!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.url">jdbc:postgresql://localhost:5432/postgres</property>
        <property name="connection.driver_class">org.postgresql.Driver</property>
        <property name="connection.username">postgres</property>
        <property name="connection.password">****</property>
        <property name="transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory</property>

        <!-- SQL dialect -->
        <property name="dialect">org.hibernate.dialect.PostgreSQLDialect</property>

        <!-- Echo all executed SQL to stdout -->
        <property name="show_sql">true</property>

        <!-- Enable Hibernate's automatic session context management -->
        <property name="current_session_context_class">thread</property>

        <!-- Drop and re-create the database schema on startup -->
        <property name="hbm2ddl.auto">create</property>

        <mapping resource="src/main/resources/Movies.hbm.xml"/>

    </session-factory>

</hibernate-configuration>

jdbc:postgresql://localhost:5432/postgres
org.postgresql.Driver
博士后
****
org.hibernate.transaction.jdbc事务工厂
org.hibernate.dialogue.PostgreSqlDialogue
真的
线
创造
Movies.hbm.xml

<?xml version="1.0"?>
<!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.hp.videotheek">
    <class name="Movies" table="movies">
        <id name="movie_id" column="movie_id">
            <generator class="increment"/>
        </id>
        <property name="movie_name" type="string" column="movie_name"/>
    </class>
</hibernate-mapping>

在屏幕截图中,您可以看到我如何设置映射以及文件在项目中的位置


我解决了自己的问题,而不是在映射中提供拥抱url

<mapping resource="Movies.hbm.xml"/>


因此,现在他只需查看hibernate.cfg.xml文件所在的地图,就会立即找到它

只要检查类路径的起始位置,它是src文件夹吗?从该点开始映射资源属性值。否在两个case中编译器都找不到资源