Hello

Pls, read the following SO post first

Could be consider to add a new Application Property such as spring.sql.init.missing.scripts with enum values such as ignore (as default) error in case that the expected sql files are not found?

To be honest I expected receive a kind of error, but it did not happen. And if the comments on SO post are correct, it is not indicated at 9.3. Initialize a Database Using Basic SQL Scripts

Thanks for your understanding

Comment From: wilkinsona

We probably need to document this better. You can make the scripts mandatory by configuring spring.sql.init.schema-locations and spring.sql.init.data-locations with values that don't use the optional: prefix.

Comment From: manueljordan

Thanks for the feedback

Correct, I have confirmed that spring.sql.init.schema-locations and spring.sql.init.data-locations makes the scripts files mandatory

I have confirmed that optional: makes the scripts files optional, it was tested when the file scripts do not exist as follows

spring.sql.init.schema-locations=optional:/com/manuel/jordan/mysql/v2/schema-mysqlx.sql
spring.sql.init.data-locations=optional:/com/manuel/jordan/mysql/v2/data-mysqlx.sql

About either optional or optional:, it is not mentioned at 9.3. Initialize a Database Using Basic SQL Scripts

Just as an observation, take in consideration in indicate explicitly if the classpath prefix is mandatory or not, I have tested with and without this prefix and the app works too. This test was accomplished even for with and without a jar execution, I mean, through mvn spring-boot:run and java -jar respectively - therefore 4 scenarios.

  • with classpath for not jar app execution
  • with classpath for jar app execution
  • without classpath for not jar app execution
  • without classpath for jar app execution

So theoretically at a first glance classpath is not mandatory, but ... according with this comment (written by you) in the following post:

it seems is mandatory. A clarification about your comment for the Reference documentation is valuable for the community. As usual I use the classpath prefix.

Thanks for your understanding

Comment From: manueljordan

Btw the optional: prefix does not appear for both Application Properties as follows

SpringBoot Document that scripts for database initialization are optional by default and how they can be made mandatory

and

SpringBoot Document that scripts for database initialization are optional by default and how they can be made mandatory

Not sure if is related with SB or with STS4 ...

Comment From: wilkinsona

That's a tooling issue. There's no way for the tooling to know what prefixes will work as it depends on the resource loader and any protocol resolvers. optional: will always work as it's a feature of AbstractScriptDatabaseInitializer rather than resource resolution.

Comment From: manueljordan

Thanks for confirmation, I am going to report this situation to STS4