![](/img/trans.png)
[英]Spring boot - derby database - GenerationTarget encountered exception accepting command : Error executing DDL "drop table wire"
[英]Spring boot exception error executing ddl
美好的一天,我想
我正在學習彈簧靴並從事小項目以擴展我的知識。
不知何故,我在啟動 spring boot 應用程序時遇到了異常,我不知道如何解決。
這是異常消息的一部分
Hibernate: alter table token add constraint FK79keudebybjlldk2o4i0nwqev foreign key (user_user_id) references user
2022-05-18 12:01:20.531 WARN 9092 --- [ main] o.h.t.s.i.ExceptionHandlerLoggedImpl : GenerationTarget encountered exception accepting command : Error executing DDL "alter table token add constraint FK79keudebybjlldk2o4i0nwqev foreign key (user_user_id) references user" via JDBC Statement
我不知道問題出在哪里,所以這里是存儲庫的鏈接。 據我所知,一切都應該安全無虞;(
Spring boot 可能配置為具有spring.jpa.hibernate.ddl-auto=update
,這意味着它將在需要時更新架構以匹配 Spring 應用程序的域層。
考慮到模式已經包含一些數據(表記錄),Spring 嘗試更新表以具有約束,但現有數據不遵守該約束,因此 DDL 失敗。
清理上述表的數據可能會允許 spring 執行 DDL 腳本以應用上述約束。
否則,您可以切換到spring.jpa.hibernate.ddl-auto=create
,其中 Spring 將首先從數據庫中刪除所有表,這意味着也將刪除現有數據,然后重新創建模式。 這將具有先前的數據不會違反約束的效果。 因此 spring 將能夠與 DDL 一起前進。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.