Spring cloud feign issues with @RequestLine annotations

Source: Internet
Author: User

 PackageCom.itmuch.cloud;Importorg.springframework.cloud.netflix.feign.FeignClient;ImportCom.itmuch.cloud.entity.User;Importcom.itmuch.config.FeignConfiguration;Importfeign. Param;Importfeign. Requestline;/*** Client Please go *@authorAdministrator **/@FeignClient (Name= "Microservice-provider-user", configuration=feignconfiguration.class) Public Interfaceuserfeignclient {@RequestLine ("Get/simple/{id}")     PublicUser FindByID (@Param ("id") Long ID); }

Start Error: Method Getlinksfortrack not annotated with HTTP method type (ex. GET, POST)

Online Baidu is said to be @RequestLine a core feign annotation, but you are using the spring Cloud @FeignClient which uses spring MVC annotations.

This means that feign is using the Spring MVC annotations (that is, requestmapping, etc.) by default, so you need to configure the feign configuration.

Obviously my code above shows that I configured the configuration:

 package   Com.itmuch.config;  import   Org.springframework.context.annotation.Bean;  import   org.springframework.context.annotation.Configuration;  import   feign. contract; @Configuration  public  class   feignconfiguration {@Bean  public contract feignconfiguration  () { return  new   feign.    Contract.default (); }}

.. But it will still be an error. The last discovery is feignconfiguration, the name of the class. I'll just do it. A name can start normally.

May be the cause of @bean. Then I looked up the following:

@Bean is a method-level annotation that is used primarily in @configuration annotated classes, or in @component annotated classes. The ID of the added bean is the method name.

Note the ID of the add Bean is the method name.

So what is the effect of configuring a bean with the ID name of a similar name that @Configuration annotations?

<bean id= "feignconfiguration" class= "Org.springframework.context.annotation.Configuration" >

I think spring does not register the @Configuration annotated class with the spring container, because the bean that you define is the same ID as the class name, which causes spring not to register the bean.

So the equivalent is not configured to enable feign annotations, all errors:

The above is my guess, know the great God can teach a bit.

Spring cloud feign issues with @RequestLine annotations

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.