欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

31.Springboot中使用RestTemplate

一. 前言

成都創(chuàng)新互聯公司從2013年成立,我們提供高端網站建設、微信小程序開發(fā)、電商視覺設計、成都app軟件開發(fā)公司及網絡營銷搜索優(yōu)化服務,在傳統(tǒng)互聯網與移動互聯網發(fā)展的背景下,我們堅守著用標準的設計方案與技術開發(fā)實力作基礎,以企業(yè)及品牌的互聯網商業(yè)目標為核心,為客戶打造具商業(yè)價值與用戶體驗的互聯網+產品。

官網使用說明

獲取Eureka實例

public String serviceUrl() {
    InstanceInfo instance = discoveryClient.getNextServerFromEureka("STORES", false);
    return instance.getHomePageUrl();
}

步驟:

二. 導入包

pom.xml

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-eureka</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-hystrix</artifactId>
</dependency>

三. 修改啟動Application

@EnableCircuitBreaker
@EnableDiscoveryClient
public class HellloMain {
	
	@Bean
	@LoadBalanced
	RestTemplate restTemplate() {
		return new RestTemplate();
	}
	
	public static void main(String[] args) {
		SpringApplication.run(HelloMain.class, args);

	}
	
}

四. 業(yè)務使用

private int xxxx(String body) {
	RestTemplate restTemplate = new RestTemplate();
	HttpHeaders headers = new HttpHeaders();
	MediaType type = MediaType.parseMediaType("application/json");
	headers.setContentType(type);
		
	HttpEntity<String> formEntity = new HttpEntity<String>(body, headers);
		
	String result = restTemplate.postForObject(getEurkaClient("hello-module"), 
				formEntity,
				String.class);
	return 0;
}
public String getEurkaClient(String end) {
        InstanceInfo instance = discoveryClient.getNextServerFromEureka("smarthome-phihome", false);
	return instance.getHomePageUrl() + end;
}

這樣就可以在應用程序之間互相調用

本文名稱:31.Springboot中使用RestTemplate
新聞來源:http://chinadenli.net/article6/jiidig.html

成都網站建設公司_創(chuàng)新互聯,為您提供App設計云服務器、關鍵詞優(yōu)化品牌網站建設、服務器托管品牌網站設計

廣告

聲明:本網站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯

商城網站建設