httpbuilder和apache.poi.workbook maven问题

时间:2017-10-24 12:18:48

标签: maven groovy httpbuilder

在Maven POM文件中,我有以下内容:

<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>

我想在我的项目中使用HttpbuilderWorkbook来解析Excel文件。

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

Workbook book = WorkbookFactory.create(res.responseData)

错误:

  1. 如果我使用我的Maven依赖项
  2. java.lang.LinkageError: loader constraint violation in interface itable 
    initialization: when resolving method "org.apache.xerces.dom.NodeImpl
    
    1. 如果我将排除添加到stax或httpbuilder
    2. java.lang.NoSuchMethodError: javax.xml.parsers.DocumentBuilderFactory.setFeature(Ljava/lang/String;Z)V
      
      1. 如果我删除stax依赖
      2. javax.xml.stream.FactoryConfigurationError: Provider com.bea.xml.stream.EventFactory not found
        

        有关如何将HttpBuilderWorkbook一起使用的任何想法?

1 个答案:

答案 0 :(得分:0)

从http-builder依赖项中排除xerces。在我的情况下,它解决了问题

<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>