问题
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:
- If I use my Maven dependencies
java.lang.LinkageError: loader constraint violation in interface itable
initialization: when resolving method "org.apache.xerces.dom.NodeImpl
- If I add exclusion to stax or to httpbuilder
java.lang.NoSuchMethodError: javax.xml.parsers.DocumentBuilderFactory.setFeature(Ljava/lang/String;Z)V
- 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