springboot中關閉eureka server中已注冊服務列表自我保護配置


配置集群服務可以向eureka通知應用是否可以使用
a、在eureka server的application.properties中加入:
# 設為false,關閉自我保護
eureka.server.enable-self-preservation=false
# 清理間隔(單位毫秒,默認是60*1000)
eureka.server.eviction-interval-timer-in-ms=20000 

b、在個application的application.properties中加入:
# 開啟健康檢查(需要spring-boot-starter-actuator依賴)
eureka.client.healthcheck.enabled=true
# 續約更新時間間隔(默認30秒)
eureka.instance.lease-renewal-interval-in-seconds=30
# 續約到期時間(默認90秒)
eureka.instance.lease-expiration-duration-in-seconds=90


c、如果沒有加過actuator的引用,在pom.xml中加入
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>

不然啟動應用會有
“Initialization of bean failed; nested exception is java.lang.NoClassDefFoundError: org/springframework/boot/actuate/health/HealthAggregator“

 

eureka通過rest接口進行注冊

cat ./rest-api-test.xml | curl -v -X POST -H "Content-type: application/xml" -d @- http://localhost:1111/eureka/apps/rest-api-test

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM