eureka:
instance:
hostname: localhost
# 过期时间,默认90s, 可不配置
lease-expiration-duration-in-seconds: 90
# 续约时间,默认30s,可不配置
lease-renewal-interval-in-seconds: 30
# ip地址优先
prefer-ip-address: true
server:
# 关闭注册中心自我保护模式,避免注册中心不移除失效的服务,默认为true
enable-self-preservation: true
# 去除失效服务的时间间隔(毫秒)
eviction-interval-timer-in-ms: 4000
client:
# 启用eureka客户端,默认为true, 可不配置
enabled: true
# 取注册信息,默认为true,可不配置
fetchRegistry: false
# 两个心跳参数,默认都是30s,可不配置
instance-info-replication-interval-seconds: 30
registry-fetch-interval-seconds: 30
# 注册到注册中心,默认为true,可不配置
registerWithEureka: false
serviceUrl:
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8761/eureka
instance:
instance-id: ${spring.cloud.client.ip-address}:${server.port}
prefer-ip-address: true #以IP地址注册到服务中心
ip-address: 192.168.217.211
non-secure-port: 8767
#Eureka客户端向服务端发送心跳的时间间隔,单位为秒(客户端告诉服务端自己会按照该规则),默认30
lease-renewal-interval-in-seconds: 10
#Eureka服务端在收到最后一次心跳之后等待的时间上限,单位为秒,超过则剔除(客户端告诉服务端按照此规则等待自己),默认90
lease-expiration-duration-in-seconds: 30
@RestController
public class HelloController {
@Autowired
private DiscoveryClient client;
@RequestMapping(value = "/hello", method = RequestMethod.GET)
public String index() {
java.util.List<ServiceInstance> instances = client.getInstances("hello-service");
return "Hello World";
}
@RequestMapping(value = "/offline", method = RequestMethod.GET)
public void offLine(){
DiscoveryManager.getInstance().shutdownComponent();
}
}
END 十期推荐 【211期】面试官:说说为什么HTTPS是安全的 【212期】面试官:说说什么是单点登录?什么是SSO?什么是CAS? 【213期】如何保障消息中间件100%消息投递成功?如何保证消息幂等性? 【214期】面试官:聊聊常见的加密算法、原理、优缺点、用途 【215期】MySQL中事务和锁的重点和难点,一次性讲清楚! 【216期】JVM超神之路 【217期】面试官:你能说一下Redis的常见应用场景吗? 【218期】面试官:你能简单介绍一下 RabbitMQ 及它的使用场景吗 【219期】面试官:谈谈MySQL的limit用法、逻辑分页和物理分页 【220期】面试官:你能说说分布式锁,进程锁,线程锁吗? ? ~