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列表中查看,前提是有应用注册,如图: