ssm单元测试:报错java.lang.IllegalStateException: Could not load TestContextBootstrapper [null]. Specify @B

完整报错信息: java.lang.IllegalStateException: Could not load TestContextBootstrapper [null]. Specify @BootstrapWith's 'value' attribute or make the default bootstrapper class available.

解决:
spring的单元测试依赖的版本问题:
1、spring-web与spring-test版本不一致,把版本号注释掉,屏蔽最新版本消息

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

2、将版本修改为5.2.8.RELEASE

 <!--spring的单元测试-->
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>5.2.8.RELEASE</version>
        <!--     test文件夹下有效       -->
            <scope>test</scope>
        </dependency>

猜你喜欢

转载自blog.csdn.net/m0_46267375/article/details/111133600