[B,int,int,java.lang.ClassLoader,java.security.ProtectionDomain) at java.base/java.security.Acce

主要报错:

023-12-09 21:33:22,489 ERROR [main][Injector.java:214] - null
java.security.PrivilegedActionException: java.lang.NoSuchMethodException: sun.misc.Unsafe.defineClass(java.lang.String,[B,int,int,java.lang.ClassLoader,java.security.ProtectionDomain)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:573)
    at com.sun.xml.bind.v2.runtime.reflect.opt.Injector.(Injector.java:197)
    at com.sun.xml.bind.v2.runtime.reflect.opt.AccessorInjector.prepare(AccessorInjector.java:81)
    at com.sun.xml.bind.v2.runtime.reflect.opt.OptimizedAccessorFactory.get(OptimizedAccessorFactory.java:125)
    at com.sun.xml.bind.v2.runtime.reflect.Accessor$GetterSetterReflection.optimize(Accessor.java:402)
    at com.sun.xml.bind.v2.runtime.property.SingleElementLeafProperty.(SingleElementLeafProperty.java:92)
    at java.base/jdk.internal.reflect.DirectConstructorHandleAccessor.newInstance(DirectConstructorHandleAccessor.java:67)
    at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499)
    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:483)
    at com.sun.xml.bind.v2.runtime.property.PropertyFactory.create(PropertyFactory.java:128)
    at com.sun.xml.bind.v2.runtime.ClassBeanInfoImpl.(ClassBeanInfoImpl.java:181)
    at com.sun.xml.bind.v2.runtime.JAXBContextImpl.getOrCreate(JAXBContextImpl.java:514)
    at com.sun.xml.bind.v2.runtime.JAXBContextImpl.(JAXBContextImpl.java:331)
    at com.sun.xml.bind.v2.runtime.JAXBContextImpl.(JAXBContextImpl.java:139)
    at com.sun.xml.bind.v2.runtime.JAXBContextImpl$JAXBContextBuilder.build(JAXBContextImpl.java:1156)
    at com.sun.xml.bind.v2.ContextFactory.createContext(ContextFactory.java:165)
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:104)


分析:

个人理解是jdk的类加载器,在加载类对象的时候出错了。unsafe反射创建失败。一般是jdk版本的问题。

解决:

修改jdk版本

项目结构修改

[B,int,int,java.lang.ClassLoader,java.security.ProtectionDomain) at java.base/java.security.Acce_第1张图片

[B,int,int,java.lang.ClassLoader,java.security.ProtectionDomain) at java.base/java.security.Acce_第2张图片

启动时修改

这个有时候虽然项目结构修改了,但是因为某些问题启动后jdk版本依然没变,因此需要在启动时修改。

[B,int,int,java.lang.ClassLoader,java.security.ProtectionDomain) at java.base/java.security.Acce_第3张图片

[B,int,int,java.lang.ClassLoader,java.security.ProtectionDomain) at java.base/java.security.Acce_第4张图片

你可能感兴趣的:(java,开发语言)