首页 > 解决方案 > Apache POI 发生了非法反射访问操作

问题描述

我正在使用 Apache POI 处理 excel 文件,从 Java 9 开始,我收到这条消息,根据这篇文章JDK9:发生了非法反射访问操作。org.python.core.PySystemState我们应该等待开发人员解决这个问题,但我应该把它留在我的新生产版本中吗?我认为如果我跳过警告应该不是问题。

WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.apache.poi.util.DocumentHelper (file:/T:/Workspace/Java/Sections%20Manager/libs/poi/poi-ooxml-3.17.jar) to method com.sun.org.apache.xerces.internal.util.SecurityManager.setEntityExpansionLimit(int)
WARNING: Please consider reporting this to the maintainers of org.apache.poi.util.DocumentHelper
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release

标签: javaapache-poijava-9

解决方案


添加更新的“poi-ooxml”依赖项。它将解决上述所有警告。

<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi-ooxml</artifactId>
    <version>4.1.0</version>
</dependency>

推荐阅读