【发布时间】:2018-08-17 20:02:23
【问题描述】:
我启动了连接到 MySQL 数据库的 Spring Boot 项目。在我的application.properties 中,我输入了spring.jpa.hibernate.ddl-auto = update,但在我更新实体中的表名后,仍会创建一个新表,并且在我更新属性的列名后会创建一个新列。
## Spring DATASOURCE (DataSourceAutoConfiguration & DataSourceProperties)
spring.datasource.url = jdbc:mysql://localhost:3306/d-gdd?autoReconnect=true&useUnicode=true&characterEncoding=UTF-8&allowMultiQueries=true&useSSL=false
spring.datasource.username = root
spring.datasource.password =
## Hibernate Properties
# The SQL dialect makes Hibernate generate better SQL for the chosen database
spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5InnoDBDialect
# Hibernate ddl auto (create, create-drop, validate, update)
spring.jpa.hibernate.ddl-auto = update
【问题讨论】:
-
您的期望是什么? hibernate 不会删除你现有的表
-
我不想让 hibernate 删除现有的表,而只是将它们更新为新名称,就像我们正在执行 UPDATE TABLE X RENAME TO Y
标签: java spring hibernate spring-boot