将 org.apache.poi poi-ooxml 依赖项添加到我的项目后,我现在收到以下错误:
javax.xml.XMLConstants.W3C_XML_SCHEMA_NS_URI cannot be resolved or is not a field
当我尝试查看源代码时,不再有,eclipse 正在寻找源代码:.m2/repository/stax/stax-api/1.0.1/stax-api-1.0。 1-sources.jar
最佳答案
poi-ooxml 还导入了 stax-api,其中包含自定义版本的 javax.xml.XMLConstants。
我的解决方案是让 Maven 在我的 pom 文件中排除这个导入:
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.16</version>
<exclusions>
<exclusion>
<groupId>stax</groupId>
<artifactId>stax-api</artifactId>
</exclusion>
</exclusions>
</dependency>
关于java - Apache POI 和 XMLConstants 冲突,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46123419/