org.flywaydb.core.Flyway.getLocations()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(2.0k)|赞(0)|评价(0)|浏览(92)

本文整理了Java中org.flywaydb.core.Flyway.getLocations()方法的一些代码示例,展示了Flyway.getLocations()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Flyway.getLocations()方法的具体详情如下:
包路径:org.flywaydb.core.Flyway
类名称:Flyway
方法名:getLocations

Flyway.getLocations介绍

暂无

代码示例

代码示例来源:origin: org.seedstack.addons.flyway/flyway

private boolean locationExists(Flyway flyway) {
  for (String location : flyway.getLocations()) {
    if (location.startsWith(CLASSPATH_PREFIX)) {
      if (ClassLoaders.findMostCompleteClassLoader().getResource(location.substring(CLASSPATH_PREFIX.length())) != null) {
        return true;
      }
    } else if (location.startsWith(FILESYSTEM_PREFIX)) {
      if (new File(location.substring(FILESYSTEM_PREFIX.length())).exists()) {
        return true;
      }
    }
  }
  return false;
}

代码示例来源:origin: zonkyio/embedded-database-spring-test

protected static String[] getFlywayLocations(Flyway flyway) {
  if (flywayVersion >= 51) {
    Object configuration = getField(flyway, "configuration");
    return Arrays.stream((Object[]) invokeMethod(configuration, "getLocations"))
        .map(location -> invokeMethod(location, "getDescriptor"))
        .toArray(String[]::new);
  } else {
    return flyway.getLocations();
  }
}

代码示例来源:origin: stackoverflow.com

import org.flywaydb.core.Flyway;
public class TestClass {
public static void main(String args[]) {
  Flyway flyway = new Flyway();
  for (String location : flyway.getLocations()) {
    System.out.println(location);
  }
  flyway.setDataSource("jdbc:h2:~/test", "sa", "");
  System.out.println("Result: " + flyway.migrate());
}
}

代码示例来源:origin: ch.inftec.flyway/flyway-extension-core

public static void configure(Flyway flyway, Properties properties) throws SQLException {
    flyway.setCallbacks(new BeforeAfterCallback(properties), new RepeatableCallback(flyway));
    List<MigrationResolver> migrationResolvers = new ArrayList<>();
    for (String locationDescriptor : flyway.getLocations()) {
      migrationResolvers.add(new RepeatableMigrationResolver(flyway, "R", new Location(locationDescriptor)));
    }

    flyway.setResolvers(migrationResolvers.toArray(new MigrationResolver[0]));
  }
}

相关文章