本文主要是介绍SpringBoot测试异常 No qualifying bean of type org.springframework.boot.test.web.client.TestRestTemplate,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
问题描述
在使用Spring Boot 测试时,出现了异常
No qualifying bean of type org.springframework.boot.test.web.client.TestRestTemplate
2020-05-11 17:20:59 [main] ERROR TestContextManager:89 - Caught exception while allowing TestExecutionListener [org.springframework.boot.test.autoconfigure.SpringBootDependencyInjectionTestExecutionListener@2fd1433e] to prepare test instance [com.antfact.oplate.analysis.contract.controller.SaaSMetricControllerTest@35c9f527]
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'com.antfact.oplate.analysis.contract.controller.SaaSMetricControllerTest': Unsatisfied dependency expressed through field 'testRestTemplate'; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.boot.test.web.client.TestRestTemplate' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:584) ~[spring-beans-
这篇关于SpringBoot测试异常 No qualifying bean of type org.springframework.boot.test.web.client.TestRestTemplate的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!