首页 > 解决方案 > java.lang.NoSuchMethodError: org.apache.poi.util.POILogger.log(ILjava/lang/Object;)V

问题描述

从 excel(Office excel 2007 女士)文件中读取数据时出现以下错误。我正在使用 testNG 框架使用 selenium。

java.lang.NoSuchMethodError: 
org.apache.poi.util.POILogger.log(ILjava/lang/Object;)V

我使用的 POI jar 如下:

<!-- https://mvnrepository.com/artifact/org.apache.poi/poi -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.0.0</version>
</dependency>

<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.11</version>
</dependency>

下面是我写的代码:

    try {
        FileInputStream fin = new FileInputStream("E:/Automation/My 
        Study/Test Data.xlsx");

        System.out.println(Runtime.class.getPackage(). 
        getImplementationVersion());
        workbook = new XSSFWorkbook(fin);
        sheet = workbook.getSheet(sheetName);
        outerHM= new HashMap<String, HashMap<String, String>>();
        innerHM= new HashMap<String, String>();
        int lastRow = sheet.getLastRowNum();

        for(int i=1; i<=lastRow; i++) {
        int lastCell = sheet.getRow(i).getLastCellNum();
            for(int j=1; j<=lastCell; j++) {
                innerHM.put(sheet.getRow(0).getCell(j).getStringCellValue(), 
                sheet.getRow(i).getCell(j).getStringCellValue());

            }
            System.out.println("Printing "+ innerHM);
            outerHM.put(sheet.getRow(i).getCell(0).getStringCellValue(), 
            innerHM);
        }

    } catch (FileNotFoundException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

标签: javaexcelselenium-webdriverapache-poi

解决方案


推荐阅读