运行maven 出错: module java.base does not "opens java.lang" to unnamed module @2d127

349 阅读1分钟

错误现象

运行maven 出错, 错误信息如下:

ERROR] Error executing Maven. [ERROR] java.lang.IllegalStateException: Unable to load cache item [ERROR] Caused by: Unable to load cache item [ERROR] Caused by: Could not initialize class com.google.inject.internal.cglib.core.MethodWrapper[ERROR]Causedby:Exceptioncom.google.inject.internal.cglib.core.MethodWrapper [ERROR] Caused by: Exception com.google.inject.internal.cglib.core.CodeGenerationException: java.lang.reflect.InaccessibleObjectException-->Unable to make protected final java.lang.Class java.lang.ClassLoader.defineClass(java.lang.String,byte[],int,int,java.security.ProtectionDomain) throws java.lang.ClassFormatError accessible: module java.base does not "opens java.lang" to unnamed module @2d127a61 [in thread "main"]

环境

我的操作系统是银河麒麟桌面版V10, maven,JDK版本:

Apache Maven 3.6.3 Maven home: /usr/share/maven Java version: 17.0.9, vendor: Private Build, runtime: /usr/lib/jvm/java-17-openjdk-amd64

解决方法

发现可能是因为相对于Java版本来说maven版本过低, maven网站下载了最新版本3.9.9运行正常。