Why rett Template.put()throws「Http Client ErrrorException:404 Not Found」

1240 ワード


 
I make a put request
RestTemplate restTemplate = new RestTemplate();
restTemplate.put(new URI("http://localhost:8080/test"), dto);
which success fully hith the rest endpoint
@RequestMapping(value = "/test", method=RequestMethod.PUT)
public void test123(@RequestBody DTO dto) {
    System.out.println("phone:"+dto.getPhone()); 
}
but the「put」method on the client throws exception、even though the server is hit succelly and I don't expect return value.
Exception in thread "main" org.springframework.web.client.HttpClientErrorException: 404 Not Found
    at org.springframework.web.client.DefaultResponseErrorHandler.handleError(DefaultResponseErrorHandler.java:91)
    at org.springframework.web.client.RestTemplate.handleResponseError(RestTemplate.java:589)
    at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:547)
    at org.springframework.web.client.RestTemplate.execute(RestTemplate.java:518)
    at org.springframework.web.client.RestTemplate.put(RestTemplate.java:394)
    at com.my.Main.main(Main.java:45)
接続パスが正しいかどうかを確認します。