Reputation: 403
I have application which calling TMDB api. For api call i use Feign interface:
@FeignClient(name = "TMDb-movie", url = "${TMDB_URL}", path = "/movie")
public interface TmdbMovieRMI {
@GetMapping(value = "/{id}", consumes = MediaType.APPLICATION_JSON_VALUE)
ResponseEntity<String> findById(@PathVariable Integer id,
@RequestParam("api_key") String apiKey);
}
But when i do the request i have this error: feign.codec.DecodeException: No qualifying bean of type 'org.springframework.boot.autoconfigure.http.HttpMessageConverters' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
How to fix it?
Upvotes: 5
Views: 1590
Reputation: 4296
If you are not using webmvc (for example because you are using webflux or no web spring boot starter at all) feign clients won't work out of the box.
You have to define the encoder and decoder manually. Insert this in a @Configuration
class or in your @SpringBootApplication
class:
@Bean
public Decoder decoder(ObjectMapper objectMapper) {
return new JacksonDecoder(objectMapper);
}
@Bean
public Encoder encoder(ObjectMapper objectMapper) {
return new JacksonEncoder(objectMapper);
}
Maybe you also need this additional dependency in your pom.xml
:
<dependency>
<groupId>io.github.openfeign</groupId>
<artifactId>feign-jackson</artifactId>
</dependency>
Upvotes: 6