Feign Inheritance Support multiple produces
See original GitHub issueI 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:
- Created 8 years ago
- Reactions:2
- Comments:10 (6 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yup, I’m fine with multiple Accept, what about picking the first consumes?
No @cforce