gpt4 book ai didi

java - 更新 Apache POI 4.0 后 - 无法识别属性 'http://www.oracle.com/xml/jaxp/properties/entityExpansionLimit'

转载 作者:行者123 更新时间:2023-12-02 03:19:22 26 4
gpt4 key购买 nike

将 Apache POI 从 3.17 更新到 4.0.0 后,我上线了:

OPCPackage pck = OPCPackage.open(this.getTemplate());

异常(exception):

java.lang.IllegalArgumentException: Property 'http://www.oracle.com/xml/jaxp/properties/entityExpansionLimit' is not recognized.
at org.apache.xerces.jaxp.DocumentBuilderFactoryImpl.setAttribute(DocumentBuilderFactoryImpl.java:144)
at __redirected.__DocumentBuilderFactory.setAttribute(__DocumentBuilderFactory.java:125)
at org.apache.poi.ooxml.util.DocumentHelper.trySetXercesSecurityManager(DocumentHelper.java:143)
at org.apache.poi.ooxml.util.DocumentHelper.<clinit>(DocumentHelper.java:108)
at org.apache.poi.openxml4j.opc.internal.ContentTypeManager.parseContentTypesFile(ContentTypeManager.java:392)
at org.apache.poi.openxml4j.opc.internal.ContentTypeManager.<init>(ContentTypeManager.java:104)
at org.apache.poi.openxml4j.opc.internal.ZipContentTypeManager.<init>(ZipContentTypeManager.java:54)
at org.apache.poi.openxml4j.opc.ZipPackage.getPartsImpl(ZipPackage.java:258)
at org.apache.poi.openxml4j.opc.OPCPackage.getParts(OPCPackage.java:725)
at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:275)
at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:181)

他们说How to disable accessExternalDTD and entityExpansionLimit warnings with logback我应该排除 xerces,但我已经有了这个:

  <dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.0.0</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.0.0</version>
<exclusions>
<exclusion>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
</exclusion>
<exclusion>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
</exclusion>
</exclusions>
</dependency>

我的设置:

  • JDK 8
  • 野蝇14

返回到 3.17 修复了该问题。

最佳答案

POI 4.0.0 代码适用于最新版本的 xerces - 该代码甚至无法尝试设置实体扩展限制,因为它将首先设置 xerces 安全管理器并在那里停止 - 你会吗能够尝试添加对最新版本的 xerces 的显式依赖项吗? https://mvnrepository.com/artifact/xerces/xercesImpl/2.12.0

关于java - 更新 Apache POI 4.0 后 - 无法识别属性 'http://www.oracle.com/xml/jaxp/properties/entityExpansionLimit',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56937791/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com