Error creating bean with name 'com.cloud.feign.interfaces.xxxFeignClient': FactoryBean threw excepti

環境:java

  Spring Cloud:Finchley.M8app

  Spring Boot:2.0.0.RELEASEspa

 

報錯信息:code

  

Error creating bean with name 'com.cloud.feign.interfaces.xxxFeignClient': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalSt.PathVariable annotation was empty on 

 

Feign接口代碼:blog

@FeignClient(value = "SPRING-CLOUD-WEB-PROVIDER-GROUP2")
public interface SongFeignClient {
    @GetMapping("/call/{id}")
    public Object getSongInfo(@PathVariable int id);
}

報錯信息關鍵點:接口

  

PathVariable annotation was empty on 

  

問題就出在接口方法入參@PathVariable註解這裏,在Spring Mvc中能夠不明確指定該註解對應的參數名稱,但在feign中必須指定,不然將保如上異常,修後的正確代碼以下:get

@FeignClient(value = "SPRING-CLOUD-WEB-PROVIDER-GROUP2")
public interface SongFeignClient {
    @GetMapping("/call/{id}")
    public Object getSongInfo(@PathVariable("id") int id);
}
相關文章
相關標籤/搜索