Could not load TestContextBootstrapper [null]. Specify @BootstrapWith‘s ‘value‘ attribute...
生活随笔
收集整理的這篇文章主要介紹了
Could not load TestContextBootstrapper [null]. Specify @BootstrapWith‘s ‘value‘ attribute...
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
在測試redis集成短信驗證時使用test啟動類做單元測試,使用了spring注入。
@RunWith(SpringRunner.class) @SpringBootTest(classes = RbacApplication.class) public class SmsUtilTest extends RbacApplicationTest{@Autowiredprivate SmsHelper smsHelper;@Autowiredprivate RedisHelper redisHelper;@Testpublic void testSms() throws InterruptedException {String tel = "158****9317";//存的是key_tel_code_1_18812145852String code = smsHelper.sendSmsCode(tel, 1);log.info("驗證碼:"+code);Thread.sleep(2000);} }啟動后報錯:
java.lang.IllegalStateException: Could not load TestContextBootstrapper [null]. Specify @BootstrapWith's 'value' attribute or make the default bootstrapper class available.經(jīng)查閱博客
https://blog.csdn.net/u013939884/article/details/70214093
https://blog.csdn.net/n_fly/article/details/78173385
發(fā)現(xiàn)是自己spring-test版本太高
<dependency><groupId>org.springframework</groupId><artifactId>spring-test</artifactId><version>5.3.6</version><scope>compile</scope> </dependency> <dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-test</artifactId> </dependency>改為
<dependency><groupId>org.springframework</groupId><artifactId>spring-test</artifactId><scope>compile</scope> </dependency> <dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-test</artifactId> </dependency>就能正常啟動了
總結(jié)
以上是生活随笔為你收集整理的Could not load TestContextBootstrapper [null]. Specify @BootstrapWith‘s ‘value‘ attribute...的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: java简单题目_Java考点知识简单练
- 下一篇: 乘法原理的例题和答案_吃透高考数学17个