ADAISIW 2022-04-25 13:06 采纳率: 83.3%
浏览 49
已结题

Spring注解效果报错

问题遇到的现象和发生背景

错误以下,同样的代码别人都运行的出来我的出不来

问题相关代码,请勿粘贴截图

img

img

img

img

运行结果及报错内容
警告: Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'orderService' defined in file [C:\Users\Administrator\Desktop\spring-T3-jw2003\build\classes\com\ynnz\service\OrderService.class]: Initialization of bean failed; nested exception is java.lang.ExceptionInInitializerError
Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'orderService' defined in file [C:\Users\Administrator\Desktop\spring-T3-jw2003\build\classes\com\ynnz\service\OrderService.class]: Initialization of bean failed; nested exception is java.lang.ExceptionInInitializerError
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:553)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
    at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
    at com.ynnz.test.Test.main(Test.java:10)
Caused by: java.lang.ExceptionInInitializerError
    at org.springframework.cglib.core.KeyFactory$Generator.getProtectionDomain(KeyFactory.java:136)
    at org.springframework.cglib.core.AbstractClassGenerator.create(AbstractClassGenerator.java:206)
    at org.springframework.cglib.core.KeyFactory$Generator.create(KeyFactory.java:149)
    at org.springframework.cglib.core.KeyFactory.create(KeyFactory.java:117)
    at org.springframework.cglib.core.KeyFactory.create(KeyFactory.java:109)
    at org.springframework.cglib.core.KeyFactory.create(KeyFactory.java:105)
    at org.springframework.cglib.proxy.Enhancer.<clinit>(Enhancer.java:71)
    at org.springframework.aop.framework.CglibAopProxy.createEnhancer(CglibAopProxy.java:236)
    at org.springframework.aop.framework.CglibAopProxy.getProxy(CglibAopProxy.java:179)
    at org.springframework.aop.framework.ProxyFactory.getProxy(ProxyFactory.java:109)
    at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.createProxy(AbstractAutoProxyCreator.java:468)
    at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.wrapIfNecessary(AbstractAutoProxyCreator.java:349)
    at org.springframework.aop.framework.autoproxy.AbstractAutoProxyCreator.postProcessAfterInitialization(AbstractAutoProxyCreator.java:298)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsAfterInitialization(AbstractAutowireCapableBeanFactory.java:422)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1583)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:545)
    ... 11 more
Caused by: 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 @205d38da
    at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:354)
    at java.base/java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:297)
    at java.base/java.lang.reflect.Method.checkCanSetAccessible(Method.java:199)
    at java.base/java.lang.reflect.Method.setAccessible(Method.java:193)
    at org.springframework.cglib.core.ReflectUtils$1.run(ReflectUtils.java:52)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
    at org.springframework.cglib.core.ReflectUtils.<clinit>(ReflectUtils.java:42)
    ... 27 more

我的解答思路和尝试过的方法

jdk是1.8版本,之前尝试过新版本的jdk,重新打过换过名字新建过项目也没用

我想要达到的结果

正常显示功能效果

  • 写回答

2条回答 默认 最新

  • a1767028198 2022-04-25 14:16
    关注

    module java.base 出现这个,最少是jdk9了 - - 自己再去检查检查吧

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 5月3日
  • 已采纳回答 4月25日
  • 创建了问题 4月25日

悬赏问题

  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改
  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法