spring cloud eureka组件rest接口及其使用

1,eureka 的rest接口文档

参考地址:https://github.com/Netflix/eureka/wiki/Eureka-REST-operations
接口示例:
spring cloud eureka组件rest接口及其使用_第1张图片

使用说明:

1,测试版本

	<parent>
		<groupId>org.springframework.bootgroupId>
		<artifactId>spring-boot-starter-parentartifactId>
		<version>1.4.2.RELEASEversion>
		<relativePath />
	parent>
	
   	
       
       <dependency>
           <groupId>org.springframework.cloudgroupId>
           <artifactId>spring-cloud-starter-eureka-serverartifactId>
       dependency>

2,application.yml 配置

#开发环境配置
spring:
    application:
        name: flow-center
server:
    port: 8761 #启动端口

eureka:
    client:
        registerWithEureka: false  #false:不作为一个客户端注册到注册中心  

3, 运行应用

4,使用rest接口访问

有坑请注意:在该版本时,使用 /eureka/v2/apps 接口,返回404错误,去掉接口中的v2,使用/eureka/apps 正常访问。不知道是不是版本问题,请看官自行测试;

示例:http://127.0.0.1:8761/eureka/apps

<applications>
<versions__delta>1versions__delta>
<apps__hashcode>UP_1_apps__hashcode>
<application>
<name>USAAUTHENTICATIONSERVERname>
<instance>
<instanceId>localhost:USAAuthenticationServer:9527instanceId>
<hostName>localhosthostName>
<app>USAAUTHENTICATIONSERVERapp>
<ipAddr>192.168.16.1ipAddr>
<status>UPstatus>
<overriddenstatus>UNKNOWNoverriddenstatus>
<port enabled="true">9527port>
<securePort enabled="false">443securePort>
<countryId>1countryId>
<dataCenterInfo class="com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo">
<name>MyOwnname>
dataCenterInfo>
<leaseInfo>
<renewalIntervalInSecs>30renewalIntervalInSecs>
<durationInSecs>90durationInSecs>
<registrationTimestamp>1553047645290registrationTimestamp>
<lastRenewalTimestamp>1553048125279lastRenewalTimestamp>
<evictionTimestamp>0evictionTimestamp>
<serviceUpTimestamp>1553047645290serviceUpTimestamp>
leaseInfo>
<metadata>
<management.port>9527management.port>
<jmx.port>61114jmx.port>
metadata>
<homePageUrl>http://localhost:9527/homePageUrl>
<statusPageUrl>http://localhost:9527/authen/actuator/infostatusPageUrl>
<healthCheckUrl>http://localhost:9527/authen/actuator/healthhealthCheckUrl>
<vipAddress>USAAuthenticationServervipAddress>
<secureVipAddress>USAAuthenticationServersecureVipAddress>
<isCoordinatingDiscoveryServer>falseisCoordinatingDiscoveryServer>
<lastUpdatedTimestamp>1553047645291lastUpdatedTimestamp>
<lastDirtyTimestamp>1553047645220lastDirtyTimestamp>
<actionType>ADDEDactionType>
instance>
application>
applications>

5,参数说明:
1,appId :用户为应用设置的spring.application.name名称 ,该名称可以重复,表示同一中类型的服务应用;
2,instanceId : 使用应用注册的hostName:appId:port组成,用于唯一标识一个应用;该值可以在App列表中查看,前提是有应用注册,如图:
spring cloud eureka组件rest接口及其使用_第2张图片

你可能感兴趣的:(spring,cloud)