I'm having the same issue as described by #405, but I'm opening another issue as the other has been closed. Basically my interface is annotated as follows:
@FeignClient(value = "${mio.core.api.url}", configuration = MioCoreServiceFeignConfiguration.class)
@Component
public interface MioCoreService {
String CONSUME_TYPE = "application/vnd.nativ.mio.v1+json";
@RequestMapping(value = "/objects/{objectId}", method = RequestMethod.GET, consumes = CONSUME_TYPE)
MioReferenceLink getObject(@PathVariable("objectId") long objectId);
but when the application starts I get the exception
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mioCoreService': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalStateException: Method getObject not annotated with HTTP method type (ex. GET, POST)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:175)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.getObjectFromFactoryBean(FactoryBeanRegistrySupport.java:103)
at org.springframework.beans.factory.support.AbstractBeanFactory.getObjectForBeanInstance(AbstractBeanFactory.java:1585)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:254)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1192)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1116)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:545)
... 45 common frames omitted
Caused by: java.lang.IllegalStateException: Method getObject not annotated with HTTP method type (ex. GET, POST)
at feign.Util.checkState(Util.java:117)
at feign.Contract$BaseContract.parseAndValidateMetadata(Contract.java:94)
at feign.Contract$BaseContract.parseAndValidatateMetadata(Contract.java:61)
at feign.hystrix.HystrixDelegatingContract.parseAndValidatateMetadata(HystrixDelegatingContract.java:24)
at feign.ReflectiveFeign$ParseHandlersByName.apply(ReflectiveFeign.java:137)
at feign.ReflectiveFeign.newInstance(ReflectiveFeign.java:55)
at feign.Feign$Builder.target(Feign.java:198)
at org.springframework.cloud.netflix.feign.FeignClientFactoryBean.loadBalance(FeignClientFactoryBean.java:132)
at org.springframework.cloud.netflix.feign.FeignClientFactoryBean.getObject(FeignClientFactoryBean.java:149)
at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:168)
... 53 common frames omitted
I've attached the full stack trace. fullstacktrace.txt
If I add the feign.RequestLine annotation it works:
@RequestLine("GET " + "/objects/{objectId}")
@RequestMapping(value = "/objects/{objectId}", method = RequestMethod.GET, consumes = CONSUME_TYPE)
MioReferenceLink getObject(@PathVariable("objectId") long objectId);
It appears that Spring Cloud Feign is ignoring the @RequestMapping annotations for some reason. I'm using Spring Cloud v1.1.0.M4. I've attached the /autoconfig output as well autoconfig.txt
Thanks
Nick
Comment From: nickcodefresh
Apologies, it turns out that for historic reasons I had the following configuration:
@Configuration
public class FeignConfiguration {
@Bean
public Contract feignContract() {
return new Contract.Default();
}
}
Removing that solved the issue
Comment From: MukundPatel1809
I was getting Caused by: java.lang.IllegalStateException: Method getObject not annotated with HTTP method type (ex. GET, POST) at feign.Util.checkState(Util.java:117) at feign.Contract$BaseContract.parseAndValidateMetadata(Contract.java:94)
I was using Default contract of feign. Then I replaced it with mvc contract and it worked. contract(new SpringMvcContract())