Flyway can't find classpath:db/migrations

前端 未结 4 1817
忘了有多久
忘了有多久 2021-01-12 22:48

I just started right now a new project in Intellij using Spring Boot ver 2.1.3 and Flyway 5.2.4 with Java 11.

After try to start my project i got :

C         


        
相关标签:
4条回答
  • 2021-01-12 23:06

    I had a similar error, and solved it as follows: I added these commands

    spring.flyway.baselineOnMigrate=true
    spring.flyway.check-location=true
    spring.flyway.locations=classpath:db/migration
    spring.flyway.schemas=public
    spring.flyway.enabled=true
    

    to application.properties

    0 讨论(0)
  • 2021-01-12 23:16

    I believe that Flyway requires at least one migration script to initialize. Try adding a simple sql creation script into your migration folder and give it another try. Alternatively you can disable the flyway dependency until you need it.

    0 讨论(0)
  • 2021-01-12 23:26

    Even when having your migration files in the db/migration folder, flyway won't detect it.

    Then you will have to fix this by explicitly setting the locations in your application.properties (or appliocation.yml) by adding:

    spring.flyway.locations=classpath:db/migration
    
    0 讨论(0)
  • 2021-01-12 23:28

    It is not that much useful or accurate answer.

    But This issue make you frustrated so that i give this solution.

    Note: Strange but it's true, Sometime it's not allow copy paste because your folder created db.migration and it expact db->migration(It's not same in this scenario). So whenever you start from scratch. Go to the resource folder -> Create DB folder -> Create migration folder -> Create database file with Version_SubVersion__Name(As defined below).

    Normally this happens in following cases,

    1. Path is not proper try using set locations param value.
    2. db.migrate folder not contain any file.
    3. Check name of file : V1_1__(short_desc)
    4. Try to run using, mvn compile flyway:migrate

    In my case i already place sql file over there but still it gives same error, Basically i place this sql file using copy paste from somewhere.

    When i try to add one new file on same place using IDE (Intellij : Right click on migration folder -> new -> Flyway migration -> versioned migration), then it ask me(warning) about some delicate allowance(normally we mention in database configuration i also place there still), and it start working.

    0 讨论(0)
提交回复
热议问题