无法在位置扫描SQL迁移:classpath:db / migration [英] Unable to scan for SQL migrations in location: classpath:db/migration

查看:2551
本文介绍了无法在位置扫描SQL迁移:classpath:db / migration的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用flyway进行SQL迁移,sql迁移完全适用于我。

I am using flyway to do the SQL migration , the sql migration worked for me perfectly .

现在我正在尝试使用Flyway进行简单的java迁移,下面是使用

Now am trying to do the simple java migration using Flyway, below is the code which am using

package db.migration;

import org.flywaydb.core.api.migration.jdbc.JdbcMigration;
import java.sql.Connection;
import java.sql.PreparedStatement;

/**
 * Example of a Java-based migration.
 */
public class V2__Test implements JdbcMigration {
public void migrate(Connection connection) throws Exception {
    PreparedStatement statement =
        connection.prepareStatement("create table test (id int)");

    try {
        statement.execute();
    } finally {
        statement.close();
    }
}
}

我创建了一个Jar文件的这个类文件,并将Jar文件放在Flyway_home / Jars文件夹下。后来我在配置文件中提到了db / migration,如下所示

I created a Jar file out of this class file and placed the Jar file under Flyway_home/Jars folder. Later I mentioned the db/migration in the config file as below

flyway.locations=db.migration

从cmd实用程序运行迁移命令之后,如下

After this am running the migrate command from cmd utility as below

flyway  -configFile=conf/flyway-fte-Data.conf migrate

我得到以下错误

ERROR: Unable to scan for SQL migrations in location: classpath:db/migration

在这里缺少什么,任何人都可以帮我解决这个问题。

What am missing here, could anyone please help me to fix this.

注意:我没有使用任何插件,它只是flyway命令行实用程序。

Note: I am not using any plugin, its just flyway command line Utility.

提前感谢。

推荐答案

属性flyway.locations配置SQL迁移文件的位置,并希望运行java迁移文件。所以我认为在你的配置中注释掉这个属性就足够了,因为Flyway_home / jars文件夹是java迁移位置属性('flyway.jarDirs')的默认值。接下来的一个可能性就是把这个属性('flyway.jarDirs')设置为你喜欢的jar位置。

The property 'flyway.locations' configures the location of the SQL migration files and you want to run the java migration files. So I think it's enough when you comment out this property in your configuarion, because the Flyway_home/jars folder is the default value for the java migration location property ('flyway.jarDirs'). The next possibility is to set this property ('flyway.jarDirs') to your favour jar location.

这篇关于无法在位置扫描SQL迁移:classpath:db / migration的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆