question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feign Inheritance Support multiple produces

See original GitHub issue

I want to use the feign inheritance support, but the the SpringMvcContract has a problem with multiple produces and consumers.

Example from http://projects.spring.io/spring-cloud/spring-cloud.html#spring-cloud-feign-inheritance:

public interface UserService {
@RequestMapping(method = RequestMethod.GET, value ="/users/{id}",  produces = { "application/hal+json", MediaType.APPLICATION_JSON_VALUE })
    User getUser(@PathVariable("id") long id);
}
@RestController
public class UserResource implements UserService {

}
@FeignClient("users")
public interface UserClient extends UserService {

}
Caused by: java.lang.IllegalStateException: Method userClient can only contain at most 1 produces field. Found: [application/hal+json, application/json]
    at feign.Util.checkState(Util.java:117)
    at org.springframework.cloud.netflix.feign.support.SpringMvcContract.checkAtMostOne(SpringMvcContract.java:113)
    at org.springframework.cloud.netflix.feign.support.SpringMvcContract.parseProduces(SpringMvcContract.java:195)
    at org.springframework.cloud.netflix.feign.support.SpringMvcContract.processAnnotationOnMethod(SpringMvcContract.java:103)
    at feign.Contract$BaseContract.parseAndValidateMetadata(Contract.java:92)
    at feign.Contract$BaseContract.parseAndValidatateMetadata(Contract.java:61)
    at feign.ReflectiveFeign$ParseHandlersByName.apply(ReflectiveFeign.java:137)
    at feign.ReflectiveFeign.newInstance(ReflectiveFeign.java:55)
    at feign.Feign$Builder.target(Feign.java:198)
    at feign.Feign$Builder.target(Feign.java:194)
    at org.springframework.cloud.netflix.feign.FeignClientFactoryBean.getObject(FeignClientFactoryBean.java:142)
    at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:168)
    ... 25 more

It would be better to use the first producer or consumer

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:2
  • Comments:10 (6 by maintainers)

github_iconTop GitHub Comments

2reactions
spencergibbcommented, Feb 5, 2016

Yup, I’m fine with multiple Accept, what about picking the first consumes?

0reactions
spencergibbcommented, Jul 18, 2017
Read more comments on GitHub >

github_iconTop Results From Across the Web

Spring Cloud OpenFeign
Feign supports boilerplate apis via single-inheritance interfaces. This allows grouping common operations into convenient base interfaces. UserService.java.
Read more >
Can a Spring Cloud Feign client share interface with an ...
Feign supports boilerplate apis via single-inheritance interfaces. This allows grouping common operations into convenient base interfaces.
Read more >
Using Feign REST Client for Service Invocation - Javatpoint
Step 1: Select currency-conversion-service project. Step 2: Open the pom.xml and add the Feign dependency. Feign inherits from the Netflix.
Read more >
Feign makes writing java http clients easier - Gitee
Feign can produce multiple api interfaces. ... Feign supports this pattern via single-inheritance interfaces. Consider the example:.
Read more >
Introduction to Spring Cloud OpenFeign - Baeldung
Feign supports multiple clients for different use cases, including the ApacheHttpClient, which sends more headers with the request, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found