spring-native
spring-native copied to clipboard
Flyway Support
Hello, i tried to get flyway up and running with spring native. Which is a very important library for us, because it's basically used for every JPA related projected. So I am wondering, way nobody else already raised an issue.
The problem is, that flyway is not capable of reading the migration scripts:
... Flyway failed to initialize: none of the following migration scripts locations could be found: - classpath:db/migration ...
I also tried to have the migration scripts inside the filesystem, at least for a workaround, but this also did not work
... caused by: java.lang.NullPointerException: null at org.flywaydb.core.internal.util.FileCopyUtils.copy(FileCopyUtils.java:124) ~[na:na] at org.flywaydb.core.internal.util.FileCopyUtils.copyToString(FileCopyUtils.java:84) ~[na:na] at org.flywaydb.core.internal.license.VersionPrinter.readVersion(VersionPrinter.java:121) ~[na:na] ...
So flyway seems to have some trouble to read files either from the classpath or FS.
Libraries:
- Spring Boot 2.4.4
- Spring Native 0.9.2
- Flyway 7.1.1 (managed by spring boot dependencies)
There is an old issue that explains how it was solved for quarkus: https://github.com/micronaut-projects/micronaut-flyway/issues/12
For documentation purposes - I created a PR that was rejected and closed for various reasons. If someone wants to create a PR again, it may make sense to take a quick look at it.
When will this feature be supported ? thanks
@cschaible thank u for the amazin work that you have done here .. and it's said that the PR was rejected i tried to get it running by basically just adding the classes to my local project. But no matter what i do, the build will complain about BufferLogCreator beeing accessed during build time. Even if i explictly set it to Initialization at Runtime. This using the latest Versions of Spring / Native. Do you have an idea ? https://github.com/goafabric/person-service/actions/runs/2502215038
@goafabric The BufferLogCreator
issue can be solved by replacing Flyway's LogFactory
and Log
classes in FlywayFeature
and NativePathLocationScanner
with LoggerFactory
from slf4j.
The InitializationHint
for the NativePathLocationScanner
in the Application
class isn't recognized. Therefore I've added the configuration to the buildArgs
in build.gradle.kts
.
If you use MariaDB you have to add additional hints.
You can see all the adjustments I made to get it running with Spring Boot 2.7.0 here.
I'm not 100% sure how the plugin configuration has to be translated to Maven but I hope this helps.
@cschaible thank you very much .. will retry [edit] after a while got it working, thx again .. but this stuff really needs to go somewhere graalvm or spring boot i watched the spring native video from spring i/o where they also announced that there are plans about graalvm repo contributions .. but afaik nothing has surfaced since
@cschaible the latest spring native 0.12.1 breaks the progress for flyway, the dreaded BufferedLogCreator Problem returns the changelog mentions a change for InitializationHints ... already tried a bunch of different stuff, but can't get it working with that version
do you have an idea ?
@goafabric Currently I have no idea, how to solve the problem. My attempts have also failed. At the moment I don't have enough time to look into it in more detail. I think you have to wait until someone with more experience solves the implementation properly and hopefully finally. I could imagine that there will be some progress near the Spring Boot 3.0 release later this year.
@cschaible ok thank you .. and for taking a look
@cschaible Together with Boot 2.7.2 i was able to get it working again .. don't know if this is a coincidence or not ... Simply by adding the demanded hint. Its now also possible to finally scrap the command line parameter ...
@NativeHint(trigger = org.flywaydb.core.Flyway.class, initialization = {@InitializationHint(types = {org.flywaydb.core.internal.util.FeatureDetector.class, NativePathLocationScanner.class, org.flywaydb.core.internal.logging.buffered.BufferedLogCreator.class}, initTime = InitializationTime.BUILD)},
@sdeleuze @snicoll Flyway is now working perfectly fine with Spring Boot 3.0 RC1 So I will close this issue. Thank u and the team for the great efforts in 3.0 RC1