Hi, when upgrading flyway to 11.13.2 and beyond NativeImageResourceProviderCustomizer runs into a NoSuchMethodError as the signature of the org.flywaydb.core.internal.scanner.Scanner constructor changed.

From

public Scanner(
            final Class<I> implementedInterface,
            final ResourceNameCache resourceNameCache,
            final LocationScannerCache locationScannerCache,
            final Configuration configuration,
            final Location[] locations) {

To

 public Scanner(final Class<? extends I> implementedInterface,
        final Configuration configuration,
        final Location[] locations) {

thus autoconfiguration is not working when using native images.

The commit in flyway core: https://github.com/flyway/flyway/commit/10b665c7513d1f65daae1cac07e2d20ba17daf54#diff-4921fba01ed9eded42327d597a3d5a13b403d2bb8c9af7b85d5beb0eadc72d0e

Spring-boot-autoconfigure: 3.5.6 flyway-core: 11.13.2 flyway-database-postgresql: 11.13.2

The stacktrace showing the described:

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'entityManagerFactory': Failed to initialize dependency 'flyway' of LoadTimeWeaverAware bean 'entityManagerFactory': Error creating bean with name 'flyway': Instantiation of supplied bean failed
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:328)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:207)
        at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:970)
        at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:627)
        at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:146)
        at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:752)
        at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:439)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:318)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1361)
        at org.springframework.boot.SpringApplication.run(SpringApplication.java:1350)
        at <myapplication>
        at java.base@21.0.2/java.lang.invoke.LambdaForm$DMH/sa346b79c.invokeStaticInit(LambdaForm$DMH)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flyway': Instantiation of supplied bean failed
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainFromSupplier(AbstractAutowireCapableBeanFactory.java:1263)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1200)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:569)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:529)
        at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:339)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:373)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:337)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:315)
        ... 11 more
Caused by: java.lang.NoSuchMethodError: org.flywaydb.core.internal.scanner.Scanner.<init>(java.lang.Class, boolean, org.flywaydb.core.internal.scanner.ResourceNameCache, org.flywaydb.core.internal.scanner.LocationScannerCache, org.flywaydb.core.api.configuration.Configuration)
        at org.springframework.boot.autoconfigure.flyway.NativeImageResourceProviderCustomizer.customize(NativeImageResourceProviderCustomizer.java:38)
        at org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration$FlywayConfiguration.flyway(FlywayAutoConfiguration.java:179)
        at org.springframework.boot.autoconfigure.flyway.FlywayAutoConfiguration__BeanDefinitions$FlywayConfiguration.lambda$getFlywayInstanceSupplier$3(FlywayAutoConfiguration__BeanDefinitions.java:137)
        at org.springframework.util.function.ThrowingBiFunction.apply(ThrowingBiFunction.java:68)
        at org.springframework.util.function.ThrowingBiFunction.apply(ThrowingBiFunction.java:54)
        at org.springframework.beans.factory.aot.BeanInstanceSupplier.lambda$get$2(BeanInstanceSupplier.java:226)
        at org.springframework.util.function.ThrowingSupplier.get(ThrowingSupplier.java:58)
        at org.springframework.util.function.ThrowingSupplier.get(ThrowingSupplier.java:46)
        at org.springframework.beans.factory.aot.BeanInstanceSupplier.invokeBeanSupplier(BeanInstanceSupplier.java:259)
        at org.springframework.beans.factory.aot.BeanInstanceSupplier.get(BeanInstanceSupplier.java:226)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.obtainInstanceFromSupplier(DefaultListableBeanFactory.java:1032)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.obtainFromSupplier(AbstractAutowireCapableBeanFactory.java:1257)
        ... 19 more

Comment From: 0utplay

I am also open to fix this myself, but wanted to ask for some guidance on how you usually handle situations like this where there are breaking changes in used libs :)