Apache POI 发生了非法的反射访问操作

id5*_*500 8 java apache-poi java-9

我正在使用 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
Run Code Online (Sandbox Code Playgroud)

小智 6

添加更新的“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>
Run Code Online (Sandbox Code Playgroud)


小智 2

我遇到的错误是:警告:发生非法反射访问操作警告:org.apache.poi.util.DocumentHelper进行非法反射访问(文件:/D:/Libary/poi-3.12/poi-ooxml-3.12-20150511 .jar) 到方法 com.sun.org.apache.xerces.internal.util.SecurityManager.setEntityExpansionLimit(int) 警告:请考虑将此报告给 org.apache.poi.util.DocumentHelper 的维护者 警告:使用 --illegal -access=warn 以启用进一步非法反射访问操作的警告警告:在未来版本中将拒绝所有非法访问操作

请使用poi-3.6或更高版本,我使用poi-3