WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by org.apache.poi.util.DocumentHelper (file:/C:/Users/Administrator/.m2/repository/org/apache/poi/poi-ooxml/3.17/poi-ooxml-3.17.jar) to constructor com.sun.org.apache.xerces.internal.util.SecurityManager() 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 怎么去掉 这警告
时间: 2024-04-11 15:32:33 浏览: 578
这个警告是因为在运行时访问了不应该公开访问的类。由于警告是由Apache POI库引起的,可以尝试通过设置Java系统属性来解决这个问题。在程序的启动代码中,添加以下代码:
```java
System.setProperty("org.apache.poi.util.POILogger", "org.apache.poi.util.NullLogger");
System.setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.NoOpLog");
```
这将禁用Apache POI库的日志记录,从而消除警告。请确保在执行任何与Apache POI相关的操作之前设置这些属性。
另外,也可以考虑更新Apache POI库的版本到较新的版本,以查看是否有解决这个问题的修复。
请注意,这些警告仅仅是警告,对程序运行没有实际影响,可以忽略它们。但如果你希望消除警告,可以尝试上述方法。
相关问题
WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by org.codehaus.groovy.reflection.CachedClass$3$1 (file:/C:/Unzipthefiles/apache-maven-3.6.1/repositor/org/codehaus/groovy/groovy/2.4.5/groovy-2.4.5-indy.jar)
这个警告是由于在您的应用程序中使用了不受支持的反射操作所导致的。这可能是由于使用了旧版本的库或框架,或者由于代码中使用了不推荐的功能。
要解决这个警告,您可以尝试以下几种方法:
1. 更新您的应用程序中使用的库和框架,确保使用最新版本的软件包。
2. 检查您的代码,查找是否有使用反射操作的地方,并尝试使用更安全的替代方法。
3. 如果您使用的是Groovy语言,请确保您使用的是最新版本的Groovy,并检查是否有任何过时的功能或用法。
4. 如果您无法解决这个警告,您可以通过在启动应用程序时添加以下参数来禁用警告:
- 在命令行中运行应用程序时,可以使用`--illegal-access=deny`参数。
- 如果是在Maven项目中,可以在`pom.xml`文件中的`<build>`部分添加以下配置:
```xml
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<compilerArgs>
<arg>--illegal-access=deny</arg>
</compilerArgs>
</configuration>
</plugin>
</plugins>
```
- 如果是在Gradle项目中,可以在`build.gradle`文件中的`tasks.withType(JavaCompile)`部分添加以下配置:
```gradle
tasks.withType(JavaCompile) {
options.compilerArgs << "--illegal-access=deny"
}
```
请注意,禁用警告可能会导致某些功能无法正常工作,因此最好的解决方法是更新代码和依赖项以避免使用不受支持的反射操作。
WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by org.springframework.util.ReflectionUtils (file:/C:/Users/HUAWEI/.m2/repository/org/springframework/spring-core/5.1.4.RELEASE/spring-core-5.1.4.RELEASE.jar) to field java.lang.Enum.name WARNING: Please consider reporting this to the maintainers of org.springframework.util.ReflectionUtils 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
这似乎是一个警告信息,它表明您在使用Spring框架时可能会遇到问题,因为ReflectionUtils使用了Java语言的非公开API。建议您向Spring框架的维护者报告此问题,并考虑使用--illegal-access=warn标志以启用更多的警告信息来避免未来的问题。同时请注意,未来的Java版本中,所有非法访问操作都将被拒绝。
阅读全文
相关推荐
![-](https://img-home.csdnimg.cn/images/20241231044930.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)
![-](https://img-home.csdnimg.cn/images/20241231044955.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![-](https://img-home.csdnimg.cn/images/20241231045053.png)