我用 schema.sql 和 data.sql 從頭開始??創建了一個專案,只是為了嘗試 schema.sql 和 data.sql:
- https://github.com/rmmcosta/TestSchema 一切正常。schema.sql 中的表是在 MySql 資料庫中創建的(之前已創建并且授權已授予在 application.properties 中定義的用戶)并且 data.sql 按預期填充資料。
但是,當我將 schema.sql 和 data.sql 更改為 schema-mysql.sql 和 data-mysql.sql 并在 application.properties 中放入屬性 spring.datasource.platform=mysql schema-mysql.sql 和資料-mysql.sql 沒有被執行。沒有錯誤被拋出,簡單地說,資料庫沒有任何反應。我嘗試使用 spring boot 2.2.4 并且它作業正常,但是使用 spring boot 2.7.5 它不起作用。
你知道 spring.datasource.platform 是否被棄用了嗎?如果是這樣,您知道如何設定 application.properties 以運行 schema-mysql.sql 嗎?
提前謝謝你,里卡多
注意:我嘗試不使用 spring.datasource.platform=mysql 而使用 schema.sql 和 data.sql 并且一切正常。我嘗試了一個舊專案,spring boot 2.2.4 和 java 1.8,并且作業正常。
uj5u.com熱心網友回復:
你知道 spring.datasource.platform 是否被棄用了嗎?如果是這樣,您知道如何設定 application.properties 以運行 schema-mysql.sql 嗎?
屬性名稱更改為spring.sql.init.platform
https://github.com/spring-projects/spring-boot/blob/d870474fcd4899fac94d51311c4163832d6b109d/spring-boot-project/spring-boot-autoconfigure/src/main/resources/META-INF/additional-spring-configuration-metadata。 json#L1148
發生在 Spring Boot 2.5 中:https ://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.5.0-RC1-Configuration-Changelog
uj5u.com熱心網友回復:
您需要在 application.properties 中使用 spring.sql.init.platform 而不是 spring.datasource.platform 屬性。
請參閱最新檔案中的評論 -
此外,Spring Boot 處理 schema-${platform}.sql 和 data-${platform}.sql 檔案(如果存在),其中 platform 是 spring.sql.init.platform 的值
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/536403.html
標籤:爪哇春天弹簧靴
