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

1,eureka 的rest接口文档

参考地址:https://github.com/Netflix/eureka/wiki/Eureka-REST-operations
接口示例:
在这里插入图片描述

使用说明:

1,测试版本

	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>1.4.2.RELEASE</version>
		<relativePath />
	</parent>
	
   	<!-- 安全认证依赖组件 
   	<dependency>
           <groupId>org.springframework.boot</groupId>
           <artifactId>spring-boot-starter-security</artifactId>
       </dependency>
   -->
       <!--增加eureka-server的依赖-->
       <dependency>
           <groupId>org.springframework.cloud</groupId>
           <artifactId>spring-cloud-starter-eureka-server</artifactId>
       </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>1</versions__delta>
<apps__hashcode>UP_1_</apps__hashcode>
<application>
<name>USAAUTHENTICATIONSERVER</name>
<instance>
<instanceId>localhost:USAAuthenticationServer:9527</instanceId>
<hostName>localhost</hostName>
<app>USAAUTHENTICATIONSERVER</app>
<ipAddr>192.168.16.1</ipAddr>
<status>UP</status>
<overriddenstatus>UNKNOWN</overriddenstatus>
<port enabled="true">9527</port>
<securePort enabled="false">443</securePort>
<countryId>1</countryId>
<dataCenterInfo class="com.netflix.appinfo.InstanceInfo$DefaultDataCenterInfo">
<name>MyOwn</name>
</dataCenterInfo>
<leaseInfo>
<renewalIntervalInSecs>30</renewalIntervalInSecs>
<durationInSecs>90</durationInSecs>
<registrationTimestamp>1553047645290</registrationTimestamp>
<lastRenewalTimestamp>1553048125279</lastRenewalTimestamp>
<evictionTimestamp>0</evictionTimestamp>
<serviceUpTimestamp>1553047645290</serviceUpTimestamp>
</leaseInfo>
<metadata>
<management.port>9527</management.port>
<jmx.port>61114</jmx.port>
</metadata>
<homePageUrl>http://localhost:9527/</homePageUrl>
<statusPageUrl>http://localhost:9527/authen/actuator/info</statusPageUrl>
<healthCheckUrl>http://localhost:9527/authen/actuator/health</healthCheckUrl>
<vipAddress>USAAuthenticationServer</vipAddress>
<secureVipAddress>USAAuthenticationServer</secureVipAddress>
<isCoordinatingDiscoveryServer>false</isCoordinatingDiscoveryServer>
<lastUpdatedTimestamp>1553047645291</lastUpdatedTimestamp>
<lastDirtyTimestamp>1553047645220</lastDirtyTimestamp>
<actionType>ADDED</actionType>
</instance>
</application>
</applications>

5,参数说明:
1,appId :用户为应用设置的spring.application.name名称 ,该名称可以重复,表示同一中类型的服务应用;
2,instanceId : 使用应用注册的hostName:appId:port组成,用于唯一标识一个应用;该值可以在App列表中查看,前提是有应用注册,如图:
在这里插入图片描述

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值