内射老阿姨1区2区3区4区_久久精品人人做人人爽电影蜜月_久久国产精品亚洲77777_99精品又大又爽又粗少妇毛片

springCloud入門學(xué)習(xí)(四):Eureka元數(shù)據(jù)

Eureka元數(shù)據(jù)有兩種,分別是標(biāo)準(zhǔn)元數(shù)據(jù)和自定元數(shù)據(jù)。

成都創(chuàng)新互聯(lián)公司專業(yè)提供成都主機托管四川主機托管成都服務(wù)器托管四川服務(wù)器托管,支持按月付款!我們的承諾:貴族品質(zhì)、平民價格,機房位于中國電信/網(wǎng)通/移動機房,服務(wù)器機柜租用服務(wù)有保障!

標(biāo)準(zhǔn)元數(shù)據(jù):主機名、IP、端口號、狀態(tài)也及健康檢查等信息。這些信息會被發(fā)布在服務(wù)注冊表中,用于服務(wù)之間的調(diào)用。

自定義元數(shù)據(jù):用戶自行定義的元素,遠(yuǎn)程客戶端可訪問并且可以根據(jù)這些元素進(jìn)行一定的處理。

遠(yuǎn)程客戶端獲取元數(shù)據(jù):movie服務(wù)獲取user服務(wù)的元數(shù)據(jù)。

1、用戶微服務(wù)修改:

server:
??port:?8010
spring:
??application:
????name:?user
eureka:
??client:
????service-url:
??????default-zone:?http://localhost:8761/eureka/
??instance:
????prefer-ip-address:?true
????metadata-map:
??????#?自定義元數(shù)據(jù),k和v都可以隨意定義
??????my-metadata:?user自定義元數(shù)據(jù)

2、電影服務(wù)修改:

package?com.my.movie.controller;

import?com.my.movie.Util.ReturnUtil;
import?lombok.extern.slf4j.Slf4j;
import?org.springframework.beans.factory.annotation.Autowired;
import?org.springframework.beans.factory.annotation.Value;
import?org.springframework.cloud.client.ServiceInstance;
import?org.springframework.cloud.client.discovery.DiscoveryClient;
import?org.springframework.http.ResponseEntity;
import?org.springframework.web.bind.annotation.RequestMapping;
import?org.springframework.web.bind.annotation.RequestMethod;
import?org.springframework.web.bind.annotation.RestController;
import?org.springframework.web.client.RestTemplate;

import?java.util.HashMap;
import?java.util.List;
import?java.util.Map;

/**
?*?@author?垃圾美少女
?*/
@RestController
@Slf4j
public?class?MovieController?{

????@Autowired
????private?DiscoveryClient?discoveryClient;


????@RequestMapping(value?=?"/movie/getUserMetadata",?method?=?RequestMethod.GET)
????public?Map?getUserMetadata(){
????????try?{
????????????List<ServiceInstance>?user?=?discoveryClient.getInstances("user");
????????????return?ReturnUtil.succe***esult(user,"獲取成功");
????????}?catch?(Exception?e)?{
????????????log.error(e.getMessage(),e);
????????????return?ReturnUtil.errorResult(null,"獲取失敗");
????????}
????}
???

}

discoveryClient.getInstances(serviceId);用來獲取指定serviceId的服務(wù)的元數(shù)據(jù)。

3、訪問 http://localhost:8020/movie/getUserMetadata

springCloud入門學(xué)習(xí)(四):Eureka元數(shù)據(jù)

分享文章:springCloud入門學(xué)習(xí)(四):Eureka元數(shù)據(jù)
文章來源:http://www.rwnh.cn/article16/igiodg.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站設(shè)計公司、定制開發(fā)網(wǎng)頁設(shè)計公司移動網(wǎng)站建設(shè)、外貿(mào)網(wǎng)站建設(shè)、網(wǎng)站策劃

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quá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è)網(wǎng)站維護(hù)公司
伽师县| 东光县| 正定县| 涞源县| 德兴市| 乡城县| 吴忠市| 宜城市| 赤壁市| 商南县| 龙岩市| 河北区| 沙坪坝区| 安义县| 济南市| 濉溪县| 雷山县| 桐柏县| 蓬溪县| 鲁甸县| 大安市| 冕宁县| 聂拉木县| 万载县| 尚志市| 宿迁市| 巴林右旗| 荣成市| 汾阳市| 宁陵县| 东乡族自治县| 饶平县| 甘德县| 井研县| 泾川县| 新安县| 自贡市| 班玛县| 招远市| 宜丰县| 金门县|