Support property placeholders in @⁠Sql script paths

Prior to this commit, paths configured via the scripts attribute in
@⁠Sql were required to be final paths without dynamic placeholders;
however, being able to make script paths dependent on the current
environment can be useful in certain testing scenarios.

This commit introduces support for property placeholders (${...}) in
@⁠Sql script paths which will be replaced by properties available in
the Environment of the test's ApplicationContext.

Closes gh-33114
This commit is contained in:
Sam Brannen
2024-07-03 15:33:20 +02:00
parent 384d0e4fd5
commit abcad5dbcf
8 changed files with 100 additions and 2 deletions

View File

@@ -122,6 +122,9 @@ classpath resource (for example, `"/org/example/schema.sql"`). A path that refer
URL (for example, a path prefixed with `classpath:`, `file:`, `http:`) is loaded by using
the specified resource protocol.
As of Spring Framework 6.2, paths may contain property placeholders (`${...}`) that will
be replaced by properties stored in the `Environment` of the test's `ApplicationContext`.
The following example shows how to use `@Sql` at the class level and at the method level
within a JUnit Jupiter based integration test class: