Skip to content

Support property placeholders in @Sql script paths #33114

@kistlers

Description

@kistlers

The flyway auto-configuration in Spring Boot has the very nice feature of replacing {vendor} in any spring.flyway.locations path with database-specific values to support multiple databases easily.

The code for those replacements is in FlywayAutoConfiguration.LocationResolver: https://github.com/spring-projects/spring-boot/blob/70a5dc64f6b4160ec9c20d48d84a0869ef735df8/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration.java#L361

On the other hand, we have the convenient @Sql annotation to run SQL scripts before tests are running. It would be very nice, if {vendor} could also be part of those paths given to Sql.scripts with the same replacement logic as flyway.

I have a specific use case for that: Currently, we have two systems in place at our company (a shared library and a dedicated application) that are built to run on multiple database systems (Postgres, MySQL, MariaDB, and HsqlDB). We have set up maven, such that some tests are run multiple times with different databases in test containers using multiple maven-surefire-plugin executions. It would be great if I could still make use of the @SQL annotation in that case with the vendor replacement.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions