How to reference flyway.locations via application.

2019-03-06 07:15发布

问题:

I have a SpringBoot application running on Liberty using flyway and working with filesystem: to reference the db/migration files locally. For our deployed environment I would prefer to keep the files inside of the generated war and not in a server folder and specified directly. When I try to use classpath:db/migration I get the following:

2017-06-21 13:50:20.494  INFO 2600 --- [ecutor-thread-3] o.f.core.internal.util.VersionPrinter    : Flyway 4.2.0 by Boxfuse
2017-06-21 13:50:21.521  INFO 2600 --- [ecutor-thread-3] o.f.c.i.dbsupport.DbSupportFactory       : Database: jdbc:db2://devserver:12345/dev_database(DB2/AIX64 10.5)
2017-06-21 13:50:21.724  WARN 2600 --- [ecutor-thread-3] o.f.c.i.u.s.classpath.ClassPathScanner   : Unable to resolve location classpath:db/migration (ClassLoader: com.ibm.ws.classloading.internal.ThreadContextClassLoader@bdac658) On WebSphere an empty file named flyway.location must be present on the classpath location for WebSphere to find it!
2017-06-21 13:50:21.725  WARN 2600 --- [ecutor-thread-3] o.f.c.i.u.s.classpath.ClassPathScanner   : Unable to resolve location classpath:db/migration
2017-06-21 13:50:22.170  WARN 2600 --- [ecutor-thread-3] o.f.c.i.u.s.classpath.ClassPathScanner   : Unable to resolve location classpath:db/migration
2017-06-21 13:50:22.171  WARN 2600 --- [ecutor-thread-3] o.f.c.i.u.s.classpath.ClassPathScanner   : Unable to resolve location classpath:db/migration
2017-06-21 13:50:22.176  WARN 2600 --- [ecutor-thread-3] o.f.c.i.u.s.classpath.ClassPathScanner   : Unable to resolve location classpath:db/migration
2017-06-21 13:50:22.180  WARN 2600 --- [ecutor-thread-3] o.f.c.i.u.s.classpath.ClassPathScanner   : Unable to resolve location classpath:db/migration
2017-06-21 13:50:22.429  INFO 2600 --- [ecutor-thread-3] o.f.core.internal.command.DbValidate     : Successfully validated 2 migrations (execution time 00:00.334s)
2017-06-21 13:50:23.270  INFO 2600 --- [ecutor-thread-3] o.f.core.internal.command.DbMigrate      : Current version of schema "DEVSCHEMA": 2
2017-06-21 13:50:23.271  WARN 2600 --- [ecutor-thread-3] o.f.core.internal.command.DbMigrate      : Schema "DEVSCHEMA" has a version (2) that is newer than the latest available migration (1) !
2017-06-21 13:50:23.307  INFO 2600 --- [ecutor-thread-3] o.f.core.internal.command.DbMigrate      : Schema "DEVSCHEMA" is up to date. No migration necessary.

What is the proper way to connect the application to my db/migration folder on Liberty Profile? I have shoved an empty Flyway.Location file all over my Liberty folders with no avail.

This is Liberty 17.0.0.1, Spring-Boot 1.5.2 and Flyway-Core 4.2.0.

回答1:

the solution is given in log, you need to add an empty file flyway.location in db/flyway