Java Spring Boot ddl 自动生成器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21113154/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Spring boot ddl auto generator
提问by gorill
I'm using spring boot with spring.jpa.hibernate.ddl-auto=create
, but when application restarted, all tables drops and creates again. Is there some way to avoiding re-creation for already existing tables?
我正在使用 spring boot spring.jpa.hibernate.ddl-auto=create
,但是当应用程序重新启动时,所有表都会删除并再次创建。有没有办法避免重新创建已经存在的表?
采纳答案by samlewis
spring.jpa.hibernate.ddl-auto=update
hibernate.ddl-autoshould usually not be used in production.
hibernate.ddl-auto通常不应在生产中使用。
回答by sudar
The list of option which is used in the spring boot are
弹簧靴中使用的选项列表是
- validate:validate the schema, makes no changes to the database.
- update:update the schema.
- create:creates the schema, destroying previous data.
- create-drop:drop the schema at the end of the session
- none:is all other cases.
- 验证:验证架构,不对数据库进行任何更改。
- 更新:更新架构。
- create:创建模式,销毁以前的数据。
- create-drop:在会话结束时删除架构
- none:是所有其他情况。
So for avoiding the data lose you use update
所以为了避免数据丢失,你使用更新