项目背景:springboot2.6.2 springcloud 2021.0.0
??java代码:CloudEurekaApplication
application.yml
spring:
application:
name: eureka
eureka:
client:
#是否将自己注册到Eureka Server,默认为true,由于当前就是server,故而设置成false,表明该服务不会向eureka注册自己的信息
register-with-eureka: false
#是否从eureka server获取注册信息,由于单节点,不需要同步其他节点数据,用false
fetch-registry: false
#设置服务注册中心的URL,用于client和server端交流
service-url:
defaultZone: http://localhost:7900/eureka/,http://localhost:7901/eureka/,http://localhost:7902/eureka/
---
server:
port: 7900
eureka:
instance:
hostname: eureka-7900
spring:
config:
activate:
on-profile: 7900
---
server:
port: 7901
eureka:
instance:
hostname: eureka-7901
spring:
config:
activate:
on-profile: 7901
---
server:
port: 7902
eureka:
instance:
hostname: eureka-7902
spring:
config:
activate:
on-profile: 7902
springboo启动配置
红框部分与application.yml文件中的*on-profile: 7900对应
?
启动三个服务即可
?
启动成功
?
|