springcloud~Eureka实例搭建
生活随笔
收集整理的這篇文章主要介紹了
springcloud~Eureka实例搭建
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
服務端
build.gradle配置
dependencies {compile('org.springframework.cloud:spring-cloud-starter-netflix-eureka-server')testCompile('org.springframework.boot:spring-boot-starter-test') }dependencyManagement {imports {mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"} }bootstrap.yml相關配置
server.port: 8761 management.port: 8762eureka:instance:hostname: localhostclient:registerWithEureka: falsefetchRegistry: falseserviceUrl:defaultZone: http://localhost:8761/eureka/啟動代碼
package lind.sprindemo.eurekaServer;import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;@EnableEurekaServer @EnableDiscoveryClient @SpringBootApplication public class EurekaServerApplication {public static void main(String[] args) {SpringApplication.run(EurekaServerApplication.class, args);} }客戶端
向我們配置中心的客戶端同時也是eureka的一個客戶端,例如一個訂單服務,它的配置存儲在配置中心,它如果希望公開自己,就需要是eureka的一個客戶端。
例子
graph TD A[訂單服務]-->B(注冊) B-->C(eureka) A-->D(獲取配置) D-->E(clientserver)總結
以上是生活随笔為你收集整理的springcloud~Eureka实例搭建的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: CC框架实践(1):实现登录成功再进入目
- 下一篇: IDEA 快捷注释