【发布时间】:2014-01-09 12:39:03
【问题描述】:
我目前正在使用 spring-boot 创建一个使用 Spring MVC 和 JPA 数据的 Web 应用程序,但是我遇到了属性 spring.jpa.hibernate.ddl-auto: create 的问题,因为它似乎在第一次运行我的表 A , B , C 被正确创建。然后我填充所有 3 个表,当我关闭应用程序并重新运行它时,只有表 A 仍然包含填充的数据。
B表和C表被彻底清除了,有点奇怪。
有人知道为什么会这样吗?
我的 pom.xml 中有以下内容作为依赖项
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>0.5.0.M6</version>
</parent>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.26</version>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<!-- Web Dependencies -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf-spring3</artifactId>
</dependency>
<dependency>
<groupId>nz.net.ultraq.thymeleaf</groupId>
<artifactId>thymeleaf-layout-dialect</artifactId>
</dependency>
<!-- Persistence -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<!-- Test -->
<!-- <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot</artifactId>
<classifier>tests</classifier>
</dependency> -->
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
</dependency>
<!-- Database -->
<!--<dependency> <groupId>org.hsqldb</groupId> <artifactId>hsqldb</artifactId>
<scope>runtime</scope> </dependency> -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.26</version>
</dependency>
<!-- Validation Dependencies -->
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
</dependency>
</dependencies>
spring.jpa.hibernate.ddl-auto
【问题讨论】:
-
它对我有用。也许这些表没有被 Hibernate 删除(或创建)?如果您可以分享一个显示此问题的示例项目,将更容易诊断。
-
没有表是由hibernate创建的..它只是由于某种原因如果你离开值spring.jpa.hibernate.ddl-auto:创建一些表是在随后的从头开始完全重新创建的运行,不确定它是否与使用mysql或其他东西有关。
-
这也发生在我身上。
标签: java spring properties spring-boot