eureka所用的依赖
有了上面依赖我们可以很轻松的搭建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}