我尝试在Java8中使用Hibernate6.0和postgres,但是我遇到了一个错误:无法访问不安全的类:sun.misc.unsafe如何解决它?
org.hibernate.MappingException: Could not instantiate persister
Caused by: java.lang.IllegalArgumentException: Could not create type
at net.bytebuddy/net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:154)
at net.bytebuddy/net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:365)
at net.bytebuddy/net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:174)
at net.bytebuddy/net.bytebuddy.TypeCache$WithInlineExpunction.findOrInsert(TypeCache.java:376)
at org.hibernate.orm.core@6.0.0.Alpha6/org.hibernate.bytecode.internal.bytebuddy.ByteBuddyState.load(ByteBuddyState.java:175)
at org.hibernate.orm.core@6.0.0.Alpha6/org.hibernate.bytecode.internal.bytebuddy.ByteBuddyState.loadProxy(ByteBuddyState.java:99)
at org.hibernate.orm.core@6.0.0.Alpha6/org.hibernate.proxy.pojo.bytebuddy.ByteBuddyProxyHelper.buildProxy(ByteBuddyProxyHelper.java:56)
at org.hibernate.orm.core@6.0.0.Alpha6/org.hibernate.proxy.pojo.bytebuddy.ByteBuddyProxyFactory.postInstantiate(ByteBuddyProxyFactory.java:61)
at org.hibernate.orm.core@6.0.0.Alpha6/org.hibernate.metamodel.internal.StandardPojoEntityRepresentationStrategy.createProxyFactory(StandardPojoEntityRepresentationStrategy.java:225)
at org.hibernate.orm.core@6.0.0.Alpha6/org.hibernate.metamodel.internal.StandardPojoEntityRepresentationStrategy.<init>(StandardPojoEntityRepresentationStrategy.java:120)
at org.hibernate.orm.core@6.0.0.Alpha6/org.hibernate.metamodel.internal.StandardManagedTypeRepresentationResolver.resolveStrategy(StandardManagedTypeRepresentationResolver.java:54)
at org.hibernate.orm.core@6.0.0.Alpha6/org.hibernate.persister.entity.AbstractEntityPersister.<init>(AbstractEntityPersister.java:695)
at org.hibernate.orm.core@6.0.0.Alpha6/org.hibernate.persister.entity.SingleTableEntityPersister.<init>(SingleTableEntityPersister.java:141)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:64)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:500)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:481)
at org.hibernate.orm.core@6.0.0.Alpha6/org.hibernate.persister.internal.PersisterFactoryImpl.createEntityPersister(PersisterFactoryImpl.java:97)
... 10 more
Caused by: java.lang.UnsupportedOperationException: Could not access Unsafe class: sun.misc.Unsafe
at net.bytebuddy/net.bytebuddy.dynamic.loading.ClassInjector$UsingUnsafe$Dispatcher$Unavailable.initialize(ClassInjector.java:2006)
at net.bytebuddy/net.bytebuddy.dynamic.loading.ClassInjector$UsingUnsafe.injectRaw(ClassInjector.java:1738)
at net.bytebuddy/net.bytebuddy.dynamic.loading.ClassInjector$AbstractBase.inject(ClassInjector.java:110)
at net.bytebuddy/net.bytebuddy.dynamic.loading.ClassLoadingStrategy$ForUnsafeInjection.load(ClassLoadingStrategy.java:567)
at net.bytebuddy/net.bytebuddy.dynamic.TypeResolutionStrategy$Passive.initialize(TypeResolutionStrategy.java:100)
at net.bytebuddy/net.bytebuddy.dynamic.DynamicType$Default$Unloaded.load(DynamicType.java:6156)
at org.hibernate.orm.core@6.0.0.Alpha6/org.hibernate.bytecode.internal.bytebuddy.ByteBuddyState.lambda$load$0(ByteBuddyState.java:179)
at net.bytebuddy/net.bytebuddy.TypeCache.findOrInsert(TypeCache.java:152)
... ```
1条答案
按热度按时间5jdjgkvh1#
在运行java进程时,需要添加以下命令行标志以启用对不安全类的访问:
--add-modules jdk.unsupported