Caused by: java.lang.IllegalStateException: SpringJUnit4ClassRunner requires JUnit 4.12 or higher.

一、问题描述

今天在ssm单元测试的时候碰到:

Caused by: java.lang.IllegalStateException: SpringJUnit4ClassRunner requires JUnit 4.12 or higher.
我原本的依赖:

	<dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-test</artifactId>
      <version>5.0.3.RELEASE</version>
      <scope>test</scope>
    </dependency>


    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.11</version>
      <scope>test</scope>
    </dependency>

二、解决方案:

当使用spring 5.x版本的时候,要求junit的jar包必须是4.12及以上,换jar包版本就可以解决问题。
修改之后:

<dependency>
      <groupId>org.springframework</groupId>
      <artifactId>spring-test</artifactId>
      <version>5.0.3.RELEASE</version>
      <scope>test</scope>
    </dependency>


    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.12</version>
      <scope>test</scope>
    </dependency>
posted @ 2021-04-13 14:58  别团等shy哥发育  阅读(63)  评论(0)    收藏  举报