String urlFetchCustomers="http://localhost:8080/fetch/customers";
String urlFetchPlaces="http://localhost:8080/fetch/places";
JsonNode customerJSON = mapper.readTree("{"result":["User1","User2","User3"],"message":"Fetched customers successfully.","status":200}");
JsonNode placeJSON = mapper.readTree("{"result":["Place1","Place2","Place3"],"message":"Fetched customers successfully.","status":200}");
ResponseEntity<JsonNode> customerResponse = new ResponseEntity<JsonNode>(customerJSON, HttpStatus.OK);
ResponseEntity<JsonNode> placeResponse = new ResponseEntity<JsonNode>(placeJSON, HttpStatus.OK);
when(restTemplate.exchange(urlFetchCustomers,
Matchers.any(HttpMethod.class),
Matchers.<HttpEntity<?>> any(),
Matchers.<Class<String>> any()
)
).thenReturn(customerResponse);
when(restTemplate.exchange(urlFetchPlaces,
Matchers.any(HttpMethod.class),
Matchers.<HttpEntity<?>> any(),
Matchers.<Class<String>> any()
)
).thenReturn(placeResponse);
我想对不同的 url 使用不同的交换调用并返回相应的响应。但这会引发以下错误..有人可以帮忙吗? 在此处输入图像描述