Spring Cloud:org.springframework.web.client.HttpClientErrorException: 404 null

@RestController
@RequestMapping("/page")
public class PageController {

    @Autowired
    private RestTemplate restTemplate;

    @GetMapping("/getProduct/{id}")
    public Products getProduct(@PathVariable Integer id){
        String url = "http://127.0.0.1:9000/product/query/"+id;
        Products forObject = restTemplate.getForObject(url, Products.class);
        return forObject;
    }

}

Share an error report solution

Adding @ pathvariable annotation to the request parameter solves the problem


Read More: