我是 Spring 的新手。我终于成功地构建了我的应用程序,没有错误,但是当我查看输出时,我有很多我不理解的信息。
首先每个表都有这个错误,它似乎是一个 Hibernate/Spring 错误:
Hibernate: alter table entity.administrationaction drop constraint FKjaafjywumaavhae5kjyo34gx5
2016-11-13 12:16:41.475 ERROR 2156 --- [ main] org.hibernate.tool.hbm2ddl.SchemaExport : HHH000389: Unsuccessful: alter table entity.administrationaction drop constraint FKjaafjywumaavhae5kjyo34gx5
2016-11-13 12:16:41.475 ERROR 2156 --- [ main] org.hibernate.tool.hbm2ddl.SchemaExport : ERREUR: la relation « entity.administrationaction » n'existe pas
然后每个表都是这样:
Hibernate: drop table if exists entity.administrationaction cascade
然后每个表都是这样:
Hibernate: create table entity.administrationaction (id serial not null, action int4, creation_date timestamp, entity_class varchar(255), entity_id int4, message varchar(255), administrator_id int4, primary key (id))
所以这就像 Spring 试图删除我所有的数据库并重新创建它。为什么 ?这是正常的还是我做错了什么?
最佳答案
放在application.properties/application.yml中
spring.jpa.hibernate.ddl-auto=update
这个属性可以设置值
1. update (Update the schema if necessary)
2. create (create the schema and destroy previous data)
3. create-drop (create and then destroy the schema at the end of the session)
4. none (disable ddl handling)
5. validate (validate the schema , make no changes to the database)
关于java - hibernate : Why is it trying to drop/create database on startup?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40573342/