You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Document that scripts for database initialization are optional by default and how they can be made mandatory #36176
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?
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.
changed the title [-]Consider to add new Application Property to handle scenario on missing sql scripts files[/-][+]Document that scripts for database initialization are optional by default and how they can be made mandatory[/+]on Jul 3, 2023
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.
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.
Activity
wilkinsona commentedon Jul 3, 2023
We probably need to document this better. You can make the scripts mandatory by configuring
spring.sql.init.schema-locationsandspring.sql.init.data-locationswith values that don't use theoptional:prefix.[-]Consider to add new Application Property to handle scenario on missing sql scripts files[/-][+]Document that scripts for database initialization are optional by default and how they can be made mandatory[/+]manueljordan commentedon Jul 3, 2023
Thanks for the feedback
Correct, I have confirmed that
spring.sql.init.schema-locationsandspring.sql.init.data-locationsmakes the scripts files mandatoryI have confirmed that
optional:makes the scripts files optional, it was tested when the file scripts do not exist as followsAbout either
optionaloroptional:, it is not mentioned at 9.3. Initialize a Database Using Basic SQL ScriptsJust as an observation, take in consideration in indicate explicitly if the
classpathprefix 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, throughmvn spring-boot:runandjava -jarrespectively - therefore 4 scenarios.classpathfor not jar app executionclasspathfor jar app executionclasspathfor not jar app executionclasspathfor jar app executionSo theoretically at a first glance
classpathis 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
classpathprefix.Thanks for your understanding
manueljordan commentedon Jul 3, 2023
Btw the
optional:prefix does not appear for both Application Properties as followsand
Not sure if is related with SB or with STS4 ...
wilkinsona commentedon Jul 3, 2023
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 ofAbstractScriptDatabaseInitializerrather than resource resolution.manueljordan commentedon Jul 3, 2023
Thanks for confirmation, I am going to report this situation to STS4
Improve documentation for configuration of schema and data scripts