Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 不推荐使用flyway.setSchemas()方法的替代方法是什么?_Java_Flyway_Deprecation Warning - Fatal编程技术网

Java 不推荐使用flyway.setSchemas()方法的替代方法是什么?

Java 不推荐使用flyway.setSchemas()方法的替代方法是什么?,java,flyway,deprecation-warning,Java,Flyway,Deprecation Warning,我有多租户应用程序,要进行数据库迁移,我必须循环每个租户模式并进行迁移,但当我在代码中使用flyway.setSchema()时,它会发出不推荐的警告 替代方案是什么 List<String> schemas = getExistingTenants(); for(int i=0;i < schemas.size(); i++) { Flyway flyway = Flyway.configure().dataSource(dataSource).load();

我有多租户应用程序,要进行数据库迁移,我必须循环每个租户模式并进行迁移,但当我在代码中使用
flyway.setSchema()
时,它会发出不推荐的警告

替代方案是什么

List<String> schemas = getExistingTenants();

for(int i=0;i < schemas.size(); i++)
{
Flyway flyway = Flyway.configure().dataSource(dataSource).load();
                    flyway.setSchemas(schemas.get(i));
            flyway.migrate();
}
List schemas=getExistingTenants();
对于(int i=0;i
根据

Flyway对象的直接配置已被弃用,并将 可在Flyway 6.0中移除。改用

在您的情况下,它将类似于:

List<String> schemas = getExistingTenants();

for(int i = 0; i < schemas.size(); i++) {
    Flyway flyway = Flyway.configure().dataSource(dataSource)
                          .schemas(schemas.get(i)) // <-- configure schemas here using the
                          .load();                 // FluentConfiguration object's method
    flyway.migrate();                              // `schemas(String... schemas)`
}
List schemas=getExistingTenants();
对于(int i=0;i.schemas(schemas.get(i))//正确的方法是对对象执行此操作,就像您已经对
数据源执行的操作一样
配置:

Flyway flyway = Flyway.configure()
        .dataSource(dataSource)
        .schemas(schemas.get(i))
        .load();
flyway.migrate();
这也记录在:

已弃用:Flyway对象的直接配置已弃用,将在Flyway 6.0中删除。请改用Flyway.configure()


另请参见。

看起来OP希望单独迁移模式(每个模式可能具有相同的结构),因此将
模式
设置到列表中(而不是单独),可能不是正确的方法。@MarkrotVeel感谢您指出这一点。我将澄清这一点。再次感谢:)