Schema & data files defined via properties are not added to the resource-config.json which causes application to error on first access.
java.lang.IllegalStateException: Failed to execute CommandLineRunner
Caused by: org.h2.jdbc.JdbcSQLSyntaxErrorException: Table "xyz" not found (this database is empty);
database=h2
spring.sql.init.schema-locations=classpath*:db/${database}/schema.sql
spring.sql.init.data-locations=classpath*:db/${database}/data.sql
should translate to:
[
{ "pattern": "\\Qdb\/h2\/schema.sql\\E" },
{ "pattern": "\\Qdb\/h2\/data.sql\\E" },
]
Comment From: sdeleuze
In order to be consistent with the strategy followed by other resource hints, I think what should be add by default is resource hints for schema.sql, schema-*.sql, data.sql and data-*.sql in addition to the one specified in spring.sql.init.schema-locations and spring.sql.init.data-locations.
Comment From: wilkinsona
in addition to the one specified in
spring.sql.init.schema-locationsandspring.sql.init.data-locations
I don't think this would be consistent. For example, WebResourcesRuntimeHintsRegistrar only registers the default static resource locations (https://github.com/spring-projects/spring-boot/issues/31278).
Comment From: sdeleuze
Indeed, should we begin by just registering the defaults and evaluate later (other issue) if we provide a mechanism for providing hints for spring.sql.init.schema-locations and spring.sql.init.data-locations custom values?
Comment From: wilkinsona
Yeah, I think that's a good way forward.
Comment From: mhalbritter
This can be tested with the jdbc smoke test.