问题描述
在使用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-