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