文章目录

1. 现象

执行命令

xjar.exe java -jar  unified-access-center-passwd.jar

运行 sprinbgboot 打包的jar包报错
具体信息如下:

C:\Users\gblfy\Desktop\xJarDir>xjar.exe java -jar  unified-access-center-passwd.jar
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by io.xjar.reflection.XReflection (file:/C:/Users/gblfy/Desktop/xJarDir/unified-access-center-passwd.jar) to field java.net.URLClassLoader.ucp
WARNING: Please consider reporting this to the maintainers of io.xjar.reflection.XReflection
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
Exception in thread "main" java.lang.reflect.InaccessibleObjectException: Unable to make public jdk.internal.loader.Resource jdk.internal.loader.URLClassPath.getResource(java.lang.String) accessible: module java.base does not "exports jdk.internal.loader" to unnamed module @6ea6d14e
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:361)
at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:301)
at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:196)
at java.base/java.lang.reflect.Method.setAccessible(Method.java:190)
at io.xjar.reflection.XReflection.method(XReflection.java:35)
at io.xjar.boot.XBootClassLoader.<init>(XBootClassLoader.java:42)
at io.xjar.boot.XJarLauncher.createClassLoader(XJarLauncher.java:31)
at org.springframework.boot.loader.ExecutableArchiveLauncher.createClassLoader(ExecutableArchiveLauncher.java:109)
at org.springframework.boot.loader.Launcher.launch(Launcher.java:55)
at io.xjar.boot.XJarLauncher.launch(XJarLauncher.java:26)
at io.xjar.boot.XJarLauncher.main(XJarLauncher.java:22)
panic: exit status 1

goroutine 1 [running]:
main.main()
2. 异常截图

Unable to make public jdk.internal.loader.Resource jdk.internal.loader.URLClassPath.getResource(jav_java

2. 解决方案

在java后面添加​​--add-opens java.base/jdk.internal.loader=ALL-UNNAMED --add-opens jdk.zipfs/jdk.nio.zipfs=ALL-UNNAMED​

3. 执行命令
xjar.exe java --add-opens java.base/jdk.internal.loader=ALL-UNNAMED --add-opens jdk.zipfs/jdk.nio.zipfs=ALL-UNNAMED  -jar  unified-access-center-passwd.jar
4. 启动日志

Unable to make public jdk.internal.loader.Resource jdk.internal.loader.URLClassPath.getResource(jav_spring boot_02

5. 浏览器效果图

Unable to make public jdk.internal.loader.Resource jdk.internal.loader.URLClassPath.getResource(jav_jar_03