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

31.Springboot中使用RestTemplate

一. 前言

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

官網(wǎng)使用說明

獲取Eureka實例

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

步驟:

二. 導(dǎo)入包

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è)務(wù)使用

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;
}

這樣就可以在應(yīng)用程序之間互相調(diào)用

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

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供App設(shè)計云服務(wù)器關(guān)鍵詞優(yōu)化品牌網(wǎng)站建設(shè)服務(wù)器托管品牌網(wǎng)站設(shè)計

廣告

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

商城網(wǎng)站建設(shè)