java - 找到接口(interface) org.apache.poi.util.POILogger,但预期类错误

标签 java maven selenium-webdriver apache-poi

public String readExcel(String columnname,String UserType) {


        try {
            FileInputStream file = new FileInputStream(path);
            @SuppressWarnings("resource")
            XSSFWorkbook wr = new XSSFWorkbook(file);
            XSSFSheet sh = wr.getSheet(prop.getProperty("env"));
            int row = sh.getPhysicalNumberOfRows();
            System.out.println(row);

                for(int j=0;j<row;j++) {
                    if((sh.getRow(j).getCell(1).getStringCellValue()).equalsIgnoreCase(UserType)) {
                        for(int i=0;i<row;i++) {
                            String s=sh.getRow(0).getCell(i).getStringCellValue();
                            if(s.equals(columnname)) {
                                 value = sh.getRow(0).getCell(i).getStringCellValue();
                            }
                        }
                    }
                }
            }catch (FileNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        catch (IOException e) {
            e.printStackTrace();
        }
        return value;
    }
    public static void main(String args[]) {
        Util obj=new Util();
        obj.readExcel("Username","Testuser1");
    }

我正在使用此代码从 Excel 中读取数据,但在线程“main”java.lang.IncompatibleClassChangeError: Found interface org.apache.poi.util.POILogger, but class was expected 中出现异常.
不知道是什么原因,谁能帮帮我?

最佳答案

将此添加到您的 pom.xml 文件中

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

的版本poi-ooxml 兴趣点 应该是一样的。

我假设您已经拥有 兴趣点 在你的 pom.xml 文件中
<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi</artifactId>
    <version>x.x.x</version>
</dependency>

希望这可以帮助

关于java - 找到接口(interface) org.apache.poi.util.POILogger,但预期类错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58147646/

相关文章:

java - 更改 JTextArea 的背景颜色时的工件

java - 从 JTable 中的一行生成标准差图

android - 私有(private) bitbucket maven repo

java - 通过 maven2 的网络应用程序

selenium - 如何使用selenium webdriver处理ModalDialog?

java - 如何使用 Struts 2 OGNL 标签将 ArrayList 从 session 迭代到 JSP

java - 什么时候应该使用封装?

maven - InvocationTargetException:javax/persistence/Persistence

python - 在 Selenium 中找不到项目时如何引发错误并转到其他功能

python - 在 selenium python 中使用 xpath