2022-04-13

Resolved: No qualifying bean of type 'org.springframework.boot.web.client.RestTemplateBuilder'

 
JUnit
TestCase
Spring Boot


Add annotation of 
@AutoConfigureWebClient
to your test case.

org.springframework.boot.test.autoconfigure.web.client.AutoConfigureWebClient



Together with
@ContextConfiguration(classes = {LocalConfig.class})

org.springframework.test.context.ContextConfiguration


public class LocalConfig {

/**
*/
public LocalConfig() {
}
@Bean
public RestTemplate restTemplate(RestTemplateBuilder builder) {
   // Do any additional configuration here
   return builder.build();
}

}


to resolve this.

Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'org.springframework.boot.web.client.RestTemplateBuilder' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {}






No comments:

Google Referrals