8
我想從用戶的特定請求的後端調用另一個web-api。 舉例我想打電話給google FCM發送消息api發送消息給特定用戶的一個事件。在Spring-Boot中從我的服務器調用另一個休息api
是改裝有什麼辦法可以達到這個目的嗎?或者如果不是我能做到的話?
我想從用戶的特定請求的後端調用另一個web-api。 舉例我想打電話給google FCM發送消息api發送消息給特定用戶的一個事件。在Spring-Boot中從我的服務器調用另一個休息api
是改裝有什麼辦法可以達到這個目的嗎?或者如果不是我能做到的話?
This website has some nice examples for using spring's RestTemplate. 這裏是它如何工作,得到一個簡單的對象的代碼示例:
private static void getEmployees()
{
final String uri = "http://localhost:8080/springrestexample/employees.xml";
RestTemplate restTemplate = new RestTemplate();
String result = restTemplate.getForObject(uri, String.class);
System.out.println(result);
}
你並不需要一個第三方庫。春天已經有['RestTemplate'](http://docs.spring.io/spring-framework/docs/current/javadoc-api/org/springframework/web/client/RestTemplate.html) –
好吧,讓我知道我如何使用休息模板? – Kenji
做一些研究。這非常簡單。 –