我目前正在使用 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