FlyWay NoClassDefFoundError

时间:2019-07-12 14:33:15

标签: noclassdeffounderror flyway

使用BaseJavaMigration迁移时

您需要解析json字符串并获取值 为此,我使用GSON

  private String getArtifactVersion(InputStream inputStream) {
    String jsonTemplate = "";
    try {
      StringWriter writer = new StringWriter();
      IOUtils.copy(inputStream, writer, Charset.forName("UTF-8"));
      jsonTemplate = writer.toString();
    } catch (IOException ex) {
      log.error("Error read file " + ex.getMessage(), ex);
    }

    String artifactVersion = "";
    JsonObject jsonObject = new JsonParser().parse(jsonTemplate).getAsJsonObject();
    JsonArray jsonArray = jsonObject.getAsJsonArray("Parameters");
    for (int i = 0; i < jsonArray.size(); i++) {
      JsonObject arrObject = jsonArray.get(i).getAsJsonObject();
      log.info(arrObject.getAsString());
      //      if (arrObject.get.equals("ArtifactVersion")) {
      //        artifactVersion = arrObject.getString("Default");
      //        break;
      //      }
    }
    log.info(artifactVersion);
    return artifactVersion;
  }

但是当我尝试运行 gradle flywayMigrate 命令时,出现错误

原因:java.lang.NoClassDefFoundError:com / google / gson / JsonParser

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

在这里找到了解决方案。 FlyWay issues