【问题标题】:Hibernate.cfg.xml not found after deploy the web app to heroku将 Web 应用程序部署到 heroku 后找不到 Hibernate.cfg.xml
【发布时间】:2015-07-29 07:50:09
【问题描述】:

使用 maven 将 web 应用程序部署到 heroku 云后,出现日志错误:

app[web.1]: org.hibernate.HibernateException: hibernate.cfg.xml 未找到。

Web 应用程序在本地正确运行,但在云上却没有。 这是我的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="hibernate.connection.driver_class">
        com.mysql.jdbc.Driver
    </property>
    <property name="hibernate.connection.url">
        jdbc:mysql://localhost:3306/todoitemsdb
    </property>
    <property name="hibernate.connection.username">root</property>
    <property name="hibernate.connection.password">root</property>
    <property name="show_sql">true</property>
    <property name="dialect">org.hibernate.dialect.MySQLDialect</property>
    <property name="hibernate.hbm2ddl.auto">update</property>
    <!-- Mapping files -->
    <mapping class="il.ac.hit.model.User" resource="todoitems.xml"/>
    <mapping class="il.ac.hit.model.ToDoItem" resource="users.xml"/>

</session-factory>
</hibernate-configuration>

我能做什么?

【问题讨论】:

    标签: java xml hibernate maven heroku


    【解决方案1】:

    我的 hibernate.cfg.xml 在文件夹配置下的资源下

    更改以下行 cfg.configure("./config/hibernate.cfg.xml"); 到 cfg.configure("config/hibernate.cfg.xml");

    工作。

    【讨论】:

      【解决方案2】:

      确保hibernate.cfg.xml 像这样捆绑到您的 jar 中:

      your-app.jar\hibernate.cfg.xml
      

      这就是 Hibernate 尝试定位配置文件的地方。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2017-12-09
        • 2014-07-16
        • 1970-01-01
        • 2019-07-24
        • 2018-12-25
        • 2012-10-22
        • 2018-03-31
        相关资源
        最近更新 更多