httpbuilder and apache.poi.workbook maven problems

时光总嘲笑我的痴心妄想 提交于 2019-12-13 03:48:40

问题


In Maven POM file I have the following:

<dependency>
    <groupId>org.codehaus.groovy.modules.http-builder</groupId>
    <artifactId>http-builder</artifactId>
    <version>0.7.1</version>
</dependency>

<dependency>
    <groupId>org.apache.httpcomponents</groupId>
    <artifactId>httpclient</artifactId>
    <version>4.5.2</version>
</dependency>

<dependency>
    <groupId>org.apache.httpcomponents</groupId>
    <artifactId>httpcore</artifactId>
    <version>4.4.5</version>
</dependency>

<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi</artifactId>
    <version>3.17</version>
</dependency>

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

<dependency>
    <groupId>stax</groupId>
    <artifactId>stax</artifactId>
    <version>1.2.0</version>
</dependency>

I want to use Httpbuilder and Workbook in my project to parse Excel files.

def res = http.post("path": "....", "requestContentType": JSON, contentType: ContentType.BINARY)

Workbook book = WorkbookFactory.create(res.responseData)

Errors:

  1. If I use my Maven dependencies

java.lang.LinkageError: loader constraint violation in interface itable 
initialization: when resolving method "org.apache.xerces.dom.NodeImpl
  1. If I add exclusion to stax or to httpbuilder

java.lang.NoSuchMethodError: javax.xml.parsers.DocumentBuilderFactory.setFeature(Ljava/lang/String;Z)V
  1. If I delete stax dependency

javax.xml.stream.FactoryConfigurationError: Provider com.bea.xml.stream.EventFactory not found

Any ideas on how to use HttpBuilder with Workbook?


回答1:


Exclude xerces from http-builder dependencies. In my case it solved problem

<dependency>
    <groupId>org.codehaus.groovy.modules.http-builder</groupId>
    <artifactId>http-builder</artifactId>
    <version>0.7.1</version>
    <exclusions>
        <exclusion>
            <groupId>xerces</groupId>
            <artifactId>xercesImpl</artifactId>
        </exclusion>
    </exclusions>
</dependency>


来源:https://stackoverflow.com/questions/46910425/httpbuilder-and-apache-poi-workbook-maven-problems

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!