日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

springcloud 之服务注册与发现 Eureka Client

發布時間:2023/12/15 编程问答 27 豆豆
生活随笔 收集整理的這篇文章主要介紹了 springcloud 之服务注册与发现 Eureka Client 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

在上一篇文章中我們已經成功的搭建了一個基于springcloud eureka的服務發現與注冊中心,但是我們并沒有向其中注入任何服務實例,接下來我將教大家如何將現有的服務注冊到我們自己的eureka注冊中心。

注:基于demo-springboot

1.打開pom.xml加入相關依賴:

<!--eureka client--> <dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-eureka</artifactId> <version>1.4.0.RELEASE</version> </dependency>


2.打開application-dev.properties并加入以下內容:

#實例名 spring.application.name=demo-springboot #注冊中心 eureka.server.host=localhost eureka.server.port=8761 eureka.client.service-url.defaultZone=http://${eureka.server.host}:${eureka.server.port}/eureka/ #feign read timeout(10s) hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds=10000 #feign read timout disable #hystrix.command.default.execution.timeout.enabled=false #開啟eureka client健康檢查 eureka.client.healthcheck=true # 續約到期時間(默認90秒) eureka.instance.lease-expiration-duration-in-seconds=30 # 續約更新時間間隔(默認30秒) eureka.instance.lease-renewal-interval-in-seconds=10


3.打開啟動類加入相應注解@EnableEurekaClient:

@EnableEurekaClient @EnableAutoConfiguration @MapperScan({"com.example.demo.dao"}) @SpringBootApplication public class DemoSpringbootApplication {public static void main(String[] args) {SpringApplication.run(DemoSpringbootApplication.class, args); } }

右鍵run application,

瀏覽器查看我們的服務已經注冊進去了。



注:如果我們想對同一個服務注冊多個實例呢?(即服務實例集群),我們只需要復制一份項目修改一下端口重新打包發布即可,相信看到這里有的童鞋已經明白了我的意圖:為以后的分布式服務做鋪墊。


創作挑戰賽新人創作獎勵來咯,堅持創作打卡瓜分現金大獎

總結

以上是生活随笔為你收集整理的springcloud 之服务注册与发现 Eureka Client的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。