Java 带有ApachePOI的xlsx文件进程出现异常

Java 带有ApachePOI的xlsx文件进程出现异常,java,spring-boot,apache-poi,Java,Spring Boot,Apache Poi,我正在使用ApachePOI读取excel文件并对其进行处理 这是我在高水平上所做的 CloseableHttpClient client = HttpClientBuilder.create().build(); HttpGet request = new HttpGet("http://file-examples.com/wp-content/uploads/2017/02/file_example_XLSX_10.xlsx"); HttpResponse response = client

我正在使用ApachePOI读取excel文件并对其进行处理

这是我在高水平上所做的

CloseableHttpClient client = HttpClientBuilder.create().build();
HttpGet request = new HttpGet("http://file-examples.com/wp-content/uploads/2017/02/file_example_XLSX_10.xlsx");
HttpResponse response = client.execute(request); 
HttpEntity entity = response.getEntity();
InputStream inputStream = entity.getContent();  
Workbook wb = WorkbookFactory.create(inputStream);
但当create是invoke时,我得到了下面的异常

java.lang.IllegalArgumentException: InputStream of class class org.apache.commons.compress.archivers.zip.ZipArchiveInputStream is not implementing InputStreamStatistics.
    at org.apache.poi.openxml4j.util.ZipArchiveThresholdInputStream.<init>(ZipArchiveThresholdInputStream.java:63)
在xlsx中,它转到createXSSFWorkbook


但我用一个示例java项目测试了同一个场景,它正在工作。这个例外只出现在另一个项目中,它是带底拖的spring boot项目。poi和commons.compress这两个项目的依赖关系是相同的。我不明白为什么它只在那个项目中给出这个异常

你能检查一下你的类路径上有commons compress 1.18吗?请参阅并使用commons compress 1.18的最新jar。它显示在mvn dependency:tree命令中,不可能在类路径上有另一个旧的commons压缩副本?实际上,当我检查STS构建路径时,它也显示在库下。我甚至尝试在STS中更新maven依赖项,并运行mvnEclipse:eclipse命令。我后来从STS外部运行war文件,但没有出现错误。之后,我切换到不同的分支,然后从STS返回并运行,这也很有效。不确定那里到底发生了什么。你能检查一下你的类路径上是否有commons compress 1.18吗?请参阅并使用commons compress 1.18的最新jar。它显示在mvn dependency:tree命令中,不可能在类路径上有另一个旧的commons压缩副本?实际上,当我检查STS构建路径时,它也显示在库下。我甚至尝试在STS中更新maven依赖项,并运行mvnEclipse:eclipse命令。我后来从STS外部运行war文件,但没有出现错误。之后,我切换到不同的分支,然后从STS返回并运行,这也很有效。不知道那里到底发生了什么。
public static Workbook create(InputStream inp, String password) throws IOException, EncryptedDocumentException {
        InputStream is = FileMagic.prepareToCheckMagic(inp);
        FileMagic fm = FileMagic.valueOf(is);

        switch (fm) {
            case OLE2:
                POIFSFileSystem fs = new POIFSFileSystem(is);
                return create(fs, password);
            case OOXML:
                return createXSSFWorkbook(is);
            default:
                throw new IOException("Your InputStream was neither an OLE2 stream, nor an OOXML stream");
        }
    }