首页 > 其他分享 >2022.12.21初学eureka

2022.12.21初学eureka

时间:2022-12-21 22:34:44浏览次数:48  
标签:false 21 spring server instance 2022.12 eureka cloud

eureka所用的依赖



org.springframework.cloud
spring-cloud-dependencies
${spring.cloud-version}
pom
import




org.springframework.boot
spring-boot-starter-parent
2.2.4.RELEASE



org.springframework.cloud
spring-cloud-starter-netflix-eureka-server


有了上面依赖我们可以很轻松的搭建eureka,注意springboot启动类上加上@EnableEurekaServer注解开启eureka的服务
配置文件如下:
端口号
server:
port: 8762
eureka:
instance:
preferIpAddress: true

#    hostname: eureka01
instance-id: ${spring.cloud.client.ip-address}:${server.port}

client:
#registerWithEureka: false
#fetchRegistry: false
serviceUrl:
defaultZone: http://localhost:8761/eureka/
spring:
application:
name: eureka-server
当eureka单机部署的时候需要将
client:
registerWithEureka: false
fetchRegistry: false
声明为false防止eureka的自注册自拉取服务
多机部署的时候就要关闭
多机部署的时候我们更喜欢将对应的ip和端口号注册进eureka,
eureka:
instance:
preferIpAddress: true
instance-id: ${spring.cloud.client.ip-address}

标签:false,21,spring,server,instance,2022.12,eureka,cloud
From: https://www.cnblogs.com/wudixiaomengmeng/p/16997379.html

相关文章