We're in the process of upgrading to spring boot 3.1 when we encountered an issue with the combination of Spring boot, Flyway and H2.

With the loglevel set on 'WARN', the flyway scripts do not run and my SpringBootTest crashes with a jdbc exception not finding the relevant table. With the loglevel set on INFO, the test runs fine.

We've been able to pinpoint it to: <logger name="org.springframework.boot.autoconfigure.h2" level="INFO"> </logger>

It seems to be caused by code in H2ConsoleAutoConfiguration in the h2console bean:

if (logger.isInfoEnabled()) {
    this.withThreadContextClassLoader(this.getClass().getClassLoader(), () -> {
        this.logDataSources(dataSource, path);
    });
}

It is not entirely clear to me, but it seems like the relevant classes are not loaded in the right place, and are apparently wrongly dependent on the h2 console being used.

Comment From: wilkinsona

From what you have described, it sounds like the info level logging is triggering Flyway's initialization that something else then relies upon. When the log level is warn, that initialization presumably isn't happening which results in a failure. I'm struggling to think of a cause for that – perhaps a missing dependsOn relationship between some beans – so I can't diagnose the problem with the information currently provided. If you would like us to spend some more time investigating, please spend some time providing a complete yet minimal sample that reproduces the problem. You can share it with us by pushing it to a separate repository on GitHub or by zipping it up and attaching it to this issue.

Comment From: maartenjanvangool

Thank you for responding!

I'm struggling to think of a cause for that – perhaps a missing dependsOn relationship between some beans – so I can't diagnose the problem with the information currently provided.

That's a shame, but I guess not too surprising. Let me see if I can find some time this week to produce such an example, And otherwise, le'ts leave it for now...

Comment From: spring-projects-issues

If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.

Comment From: spring-projects-issues

Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.