當我們使用Springboot時(沒有flyway依賴)
一旦我們定義了一個物件模型并用@Entity標簽標記它,然后運行應用程式,似乎spring boot會自動在資料庫中創建一個表。
但是當我們添加flyway依賴時,當我們運行應用程式時,SpringBoot不會創建表,而是會拋出一個錯誤。所以唯一的解決方法是在飛行路線中創建一個表。有誰知道為什么會這樣?
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory' defined in class path resource [org/springframework/boot/autoconfigure/orm/jpa/HibernateJpaConfiguration.class]: [PersistenceUnit: default] Unable to build Hibernate SessionFactory; nested exception is org.hibernate.tool.schema.spi.SchemaManagementException: Schema-validation: missing table [singer]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1753) ~[spring-beans-6.0.0-RC3.jar:6.0.0-RC3]
uj5u.com熱心網友回復:
您可能希望在application.yml.
spring:
jpa:
hibernate:
ddl-auto: update
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/530901.html
標籤:爪哇春天弹簧靴休眠飞路
上一篇:在SpringBoot中使用RickandMorty的API回傳Null
下一篇:如何將java物件序列化為字串?
