spring-attic / spring-native

Spring Native is now superseded by Spring Boot 3 official native support
https://docs.spring.io/spring-boot/docs/current/reference/html/native-image.html
Apache License 2.0
2.74k stars 355 forks source link

PathMatchingResourcePatternResolver failed to find resources by mask like `classpath:/db/migration/*.sql` #1681

Closed vladimirfx closed 2 years ago

vladimirfx commented 2 years ago

Resources are correctly included in the image and direct paths like classpath:db/migration/V1__initial.sql work as expected.

Usage code: https://github.com/nkonev/r2dbc-migrate/blob/master/r2dbc-migrate-resource-reader-spring/src/main/java/name/nkonev/r2dbc/migrate/reader/SpringResourceReader.java

mhalbritter commented 2 years ago

This is a known limitation of native-image. Classpath resources can't be enumerated in a native-image, see https://github.com/oracle/graal/issues/1108.

mhalbritter commented 2 years ago

For Spring Boot 3, we have to see how Flyway can be supported. One idea is to enumerate the files at build time, create an index file, and use that index file when loading flyway migrations on native image runtime.

vladimirfx commented 2 years ago

For Spring Boot 3, we have to see how Flyway can be supported. One idea is to enumerate the files at build time, create an index file, and use that index file when loading flyway migrations on native image runtime.

I can file the PR with similar approach to R2DBC migration. Is there any ticket for Flyway to subscribe on?

mhalbritter commented 2 years ago

Yes, this one: https://github.com/spring-projects/spring-boot/issues/31999