【问题标题】:Database Issue in Spring MVC- HIbernate exampleSpring MVC 中的数据库问题- HIbernate 示例
【发布时间】:2012-01-05 19:45:58
【问题描述】:

当我运行example

在我的系统上使用 mvn tomcat:run 命令,

mysql 表中的数据被删除。

所以,我每次重新启动应用程序时都必须插入数据。

【问题讨论】:

  • 你想让我把代码贴在这里吗?

标签: mysql hibernate spring spring-mvc


【解决方案1】:

假设您完全按照链接页面中的教程进行操作,那么每次启动应用程序时删除 MySQL 数据的原因可以在 hibernate.cfg.xml 文件中找到。

具体来说,就是以下几行:

<!-- This will drop our existing database and re-create a new one.
      Existing data will be deleted! -->
    <property name="hbm2ddl.auto">create</property>

我不记得其他值是什么,但我相信validate 只会检查您的架构是否正确,但不会更改任何内容。 update 也可以工作。

【讨论】:

    猜你喜欢
    • 2011-01-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-01
    • 1970-01-01
    • 2015-08-15
    • 2011-06-29
    • 2014-12-01
    相关资源
    最近更新 更多