Flyway找不到classpath:db/migrations [英] Flyway can't find classpath:db/migrations
问题描述
我现在刚开始使用Intellij使用Spring Boot版本2.1.3和带有Java 11的Flyway 5.2.4在Intellij中创建一个新项目.
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 :
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flyway' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.flywaydb.core.Flyway]: Factory method 'flyway' threw exception; nested exception is java.lang.IllegalStateException: Cannot find migrations location in: [classpath:db/migration] (please add migrations or check your Flyway configuration)
我有以下文件夹:
您可以看到我具有"db/migration",但是没有任何迁移,我现在就开始了.调试类FlywayAutoConfiguration我得到以下信息:
As you can see i have "db/migration" but without any migration, i just started right now. Debugging the class FlywayAutoConfiguration i got the following:
因此,我尝试返回"classpath:"中的所有文件,请参见:
So, i tried to return all files in "classpath:", see:
请注意,我只有"application.properties"文件.
Note that i just have "application.properties" file.
推荐答案
我相信Flyway至少需要一个迁移脚本才能进行初始化.尝试将简单的sql创建脚本添加到您的迁移文件夹中,然后再尝试一次.另外,您可以禁用对飞行路线的依赖性,直到需要它为止.
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.
这篇关于Flyway找不到classpath:db/migrations的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!