使用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
我该如何解决这个问题?