解决:Reason: groovy.lang.MissingMethodException: No signature of method: static com.github.difflib.DiffUtils.htmlDiff() is applicable for argument types: (java.util.ArrayList, java.util.ArrayList) values: [["ID","NAME","NAME","EMAIL", "011","John","22","John@email.com", ...], ...]
时间: 2023-07-05 22:23:54 浏览: 98
这个错误提示说明 `DiffUtils.htmlDiff()` 方法没有接受两个 `ArrayList` 类型的参数。这是因为 `DiffUtils.htmlDiff()` 方法需要接受两个 `List<String>` 类型的参数,而不是 `ArrayList` 类型。
你可以尝试将 `ArrayList` 转换为 `List<String>` 类型,例如:
```groovy
def lines1 = Files.readAllLines(file1).toList()
def lines2 = Files.readAllLines(file2).toList()
def diff = DiffUtils.diff(lines1, lines2)
if (!diff.getDeltas().isEmpty()) {
// Differences found, generate HTML report
def html = DiffUtils.htmlDiff(lines1, lines2)
def diffFile = diffOutputFolder.resolve("${file1.fileName}-diff.html")
Files.write(diffFile, html.getBytes())
}
```
这样,`DiffUtils.htmlDiff()` 方法就可以正确地接受 `List<String>` 类型的参数了。
相关问题
groovy.lang.MissingMethodException: No signature of method: com.github.difflib.patch.ChangeDelta.getRevised() is applicable for argument types: () values: []
根据报错信息,"com.github.difflib.patch.ChangeDelta"类中没有名为"getRevised()"的方法,并且该方法没有接受任何参数。因此,您在调用"getRevised()"方法时出现了"MissingMethodException"异常。
如果您想要获取修订后的内容,可能需要查看该类的其他方法或属性来获取目标内容。请检查文档或源代码以确定正确的方法或属性名称,并相应地进行调整。
patch.getDeltas().getOriginal().getLines()时报错:groovy.lang.MissingMethodException: No signature of method: com.github.difflib.patch.ChangeDelta.getOriginal() is applicable for argument types: () values: []
根据错误信息来看,似乎是ChangeDelta类中没有名为getOriginal()的方法。而且根据你的代码,getDeltas()方法返回的是一个Delta类型的列表,而Delta类型也没有getOriginal()方法。因此,你需要先从getDeltas()方法返回的列表中获取一个Delta对象,然后再通过这个对象调用getOriginal()方法获取原始行。具体代码可能类似于以下形式:
```
List<Delta> deltas = patch.getDeltas();
Delta delta = deltas.get(0); // 获取第一个Delta对象
List<?> originalLines = delta.getOriginal().getLines(); // 获取原始行
```
需要根据你的具体情况进行调整。