gpt4 book ai didi

java - 读取 Excel 工作表数据和打印值时出现 NoClassDefFoundError

转载 作者:行者123 更新时间:2023-12-01 19:55:12 25 4
gpt4 key购买 nike

读取 Excel 工作表数据和打印值时出现 NoClassDefFoundError我收到以下代码的 classnotfound 异常:

package practice;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

import org.apache.poi.xssf.usermodel.XSSFWorkbook;

public class dataDriven {

public static void main(String[] args) throws FileNotFoundException,IOException
{
FileInputStream fis = new FileInputStream("C://Users//484834//testdata.xlsx");
XSSFWorkbook wb = new XSSFWorkbook(fis);
wb =null;

int sheets = wb.getNumberOfSheets();
System.out.println("Number of sheets is "+sheets);
}

}

输出是:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/collections4/ListValuedMap
at practice.dataDriven.main(dataDriven.java:14)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.collections4.ListValuedMap
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 1 more

最佳答案

您似乎缺少 jar 文件。您可以在构建路径中添加 commons-collections4-x.jar

相同的 URL 是 - https://mvnrepository.com/artifact/org.apache.commons/commons-collections4/4.2

希望这能解决您的问题。

关于java - 读取 Excel 工作表数据和打印值时出现 NoClassDefFoundError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59045315/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com