Home > Mobile >  spring.datasource.platform is not working
spring.datasource.platform is not working

Time:11-18

I made a project from scratch just with the schema.sql and the data.sql just to try the schema.sql and the data.sql:

  • https://github.com/rmmcosta/TestSchema Everything works fine. The table inside schema.sql is created in a MySql database (previously created and the grants were given to the user defined in application.properties) and the data.sql populates the data as it's supposed to do.

But, when I change schema.sql and data.sql to schema-mysql.sql and data-mysql.sql and I put in the application.properties the property spring.datasource.platform=mysql the schema-mysql.sql and the data-mysql.sql are not being executed. No errors are being thrown, simple nothing happens on the database. I tried with spring boot 2.2.4 and it works fine, but with spring boot 2.7.5 it isn't working.

Do you know if the spring.datasource.platform was deprecated? And if so, do you know how can I set the application.properties in order to run schema-mysql.sql?

Thank you in advance, Ricardo

Note: I tried without using spring.datasource.platform=mysql and with schema.sql and data.sql and everything works fine. I tried with an old project, spring boot 2.2.4 and java 1.8, and works fine.

CodePudding user response:

Do you know if the spring.datasource.platform was deprecated? And if so, do you know how can I set the application.properties in order to run schema-mysql.sql?

The property name changed to 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

Which occurred in Spring Boot 2.5: https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.5.0-RC1-Configuration-Changelog

CodePudding user response:

You need to use spring.sql.init.platform instead of spring.datasource.platform property in application.properties.

Please see the comment from latest documentation -

In addition, Spring Boot processes the schema-${platform}.sql and data-${platform}.sql files (if present), where platform is the value of spring.sql.init.platform

  • Related