Spring Cloud学习笔记

参考:

https://blog.csdn.net/forezp/column/info/15197

https://cloud.tencent.com/developer/news/334738

https://www.cnblogs.com/ityouknow/p/7508306.html

服务的注册与发现Eureka
server

在main所在类使用@EnableEurekaServer注解,注册成为Eureka Server

配置参考:

server:
  port: 8761

eureka:
  server:
    renewalPercentThreshold: 0.49
  instance:
    hostname: localhost
  client:
    registerWithEureka: false
    fetchRegistry: false
    serviceUrl:
      defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/

spring:
  application:
    name: eurka-server

server:port:是自身端口,defaultZone的url是client的defaultZone要填的url

client
@EnableEurekaClient注册成为Eureka Client

配置参考:

server:
  port: 8762

spring:
  application:
    name: service-hi

eureka:
  client:
    serviceUrl:
      defaultZone: http://localhost:8761/eureka/

分别启动,访问http://localhost:8761

发表评论

电子邮件地址不会被公开。 必填项已用*标注