海量的海 2023-01-04 14:21 采纳率: 100%
浏览 79
已结题

高版本的spring-context不能用junit

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

为什么高版本的spring-context不能用junit,在低版本中可以正常使用

遇到的现象和发生背景,请写出第一个错误信息

org.junit.platform.commons.JUnitException: TestEngine with ID 'junit-jupiter' failed to discover tests


Caused by: org.junit.platform.commons.JUnitException: ClassSelector [className = 'spring.TestIOC'] resolution failed
Caused by: java.lang.UnsupportedClassVersionError: org/springframework/context/ApplicationContext has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 55.0 ![img](https://img-mid.csdnimg.cn/release/static/image/mid/ask/331951318276123.png "#left")

img

img

<!-- https://mvnrepository.com/artifact/org.springframework/spring-context -->
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context</artifactId>
    <version>5.3.1</version>
</dependency>

在5.几的版本下就可以,而6.几的版本都不行

  • 写回答

2条回答 默认 最新

  • Huazie 全栈领域优质创作者 2023-01-04 14:59
    关注
    • 首先要看你的junit版本是啥, 从下面这个报错看,是 JDK版本不适配,编译的版本是 61【JDK17】, 运行环境却是 55【JDK11】

    Caused by: java.lang.UnsupportedClassVersionError: org/springframework/context/ApplicationContext has been compiled by a more recent version of the Java Runtime (class file version 61.0), this version of the Java Runtime only recognizes class file versions up to 55.0

    • JDK版本和字节码版本关系

      img

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

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 1月7日
  • 已采纳回答 1月4日
  • 修改了问题 1月4日
  • 创建了问题 1月4日

悬赏问题

  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥15 想问一下树莓派接上显示屏后出现如图所示画面,是什么问题导致的
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)
  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化