Springcloud feign 404問題
1587 ワード
一.feignを使用すると404の問題が発生した.
二:私のコードブロックは:
1.サービスプロバイダ:
2.fegin client
3.feign消費者
3:ソリューション:
GetMappingの置き換え
feign.FeignException: status 404 reading UserClientService#getById(Integer); content:
{"timestamp":1537840235636,"status":404,"error":"Not Found","message":"No message available","path":"/getById/1"}
at feign.FeignException.errorStatus(FeignException.java:62) ~[feign-core-9.5.0.jar:na]
二:私のコードブロックは:
1.サービスプロバイダ:
@Controller
@RequestMapping("/user")
public class UserController {
@Autowired
private UserService userService;
@GetMapping("/list")
@ResponseBody
public List list(){
List list = userService.list();
return list;
}
@GetMapping("/getById/{id}")
@ResponseBody
public User getById(@PathVariable Integer id){
User user = userService.getById(id);
return user;
}
}
2.fegin client
@FeignClient(value = "SPRINGCLOUD-PROVIDER-USER")
public interface UserClientService {
@GetMapping("/getById/{id}")
public User getById(@PathVariable("id") Integer id);
}
3.feign消費者
@RestController
@RequestMapping("/movie")
public class MovieController {
@Autowired
private UserClientService userClientService;
@GetMapping("/findById/{id}")
public User findById(@PathVariable Integer id) {
User user = userClientService.getById(id);
return user;
}
}
3:ソリューション:
GetMappingの置き換え