pom.xml依赖如下

        <!-- spring 单元测试组件包 -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>5.0.7.RELEASE</version>
                        <scope>test</scope>
        </dependency>
 
        <!-- 单元测试Junit -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
                        <scope>test</scope>
        </dependency>

问题解答

  上述scope配置Junit可用的位置test表示只能在src下的test文件夹下面才可以使用

解决办法

  去掉scope配置就可以

解决后的依赖包修改为如下

        <!-- spring 单元测试组件包 -->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>5.0.7.RELEASE</version>
        </dependency>
 
        <!-- 单元测试Junit -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
        </dependency>

相关文章:

  • 2021-12-21
  • 2022-12-23
  • 2022-02-18
  • 2022-12-23
  • 2022-01-15
  • 2022-12-23
  • 2019-07-16
  • 2021-10-01
猜你喜欢
  • 2022-12-23
  • 2022-02-01
  • 2021-11-12
  • 2022-12-23
  • 2021-06-05
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案