Fegin調用地方細心不對的地方:
❌錯誤誤代碼,在Fegin裏面寫這樣的代碼!!
@GetMaping(path="/users/{userId}")
Resp<UserInfo> getUserInfo(@NotEmpty @Pathvariable String userId);
上面代碼犯了2處錯誤:**
-
在Fegin調用中,不允許出現,@NotEmpty這種註釋校驗參數是否爲空的。
-
在Fegin調用中 @Pathvariable不管調用參數有幾個,一定要寫上調用的名稱@Pathvariable(“userId”)
注意:@RequestParam(“storeDeptId”) 使用 @RequestParam註解也是要寫上參數名稱,不管參數個數有幾個
Fegin調用正確代碼:✅
@GetMaping(path = "/users/{userId}")
Resp<UserInfo> getUserInfo(@Pathvariable("userId") String userId)