.NET Core微服務之基於Steeltoe使用Eureka實現服務註冊與發現

Steeltoe的官方地址:http://steeltoe.io/,其官方介紹如下:

Steeltoe is an open source project that enables .NET developers to implement industry standard best practices when building resilient microservices for the cloud. The Steeltoe client libraries enable .NET Core and .NET Framework apps to easily leverage Netflix Eureka, Hystrix, Spring Cloud Config Server, and Cloud Foundry services.  

  我們主要關注的就是這句話:enable .NET Core and .NET Framework apps to easily leverage Netflix Eureka, Hystrix, Spring Cloud Config Server, and Cloud Foundry services  => 可以使我們的.NET/.NET Core應用程序輕鬆地使用Spring Cloud的一些核心組件如Eureka、Hystrix、Config Server以及雲平臺服務(例如PCF)。這裏也可以看出,目前Steeltoe的客戶端也僅僅支持輕鬆使用這幾個組件而已。

  Spring Cloud是一個基於Java的成熟的微服務全家桶架構,它爲配置管理、服務發現、熔斷器、智能路由、微代理、控制總線、分佈式會話和集羣狀態管理等操作提供了一種簡單的開發方式,已經在國內衆多大中小型的公司有實際應用案例。許多公司的業務線全部擁抱Spring Cloud,部分公司選擇部分擁抱Spring Cloud。有關Spring Cloud的更多內容,有興趣的可以瀏覽我的這一篇《Spring Cloud微服務架構學習筆記與基礎示例》,這裏不是本文重點,不再贅述。

二、快速構建Eureka Server

  (1)使用IDE (我使用的是IntelljIdea)新建一個Spring Boot應用程序

  (2)pom.xml中增加Spring Cloud的依賴和Eureka的starter

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>

        <!-- eureka server -->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-eureka-server</artifactId>
        </dependency>
    </dependencies>

    <!-- spring cloud dependencies -->
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>Edgware.SR3</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

  (3)在啓動類上添加EnableEurekaServer註解

作者:蝴蝶刀刀

鏈接:http://www.imooc.com/article/80781

來源:慕課網

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章