- Consul
- 依赖
- 启动类
- 配置文件
- Zookeeper
- 依赖
- 配置文件
- 启动类
Consul 依赖Spring Cloud 系列笔记总目录:Spring Cloud 学习笔记
consul和zookeeper是啥就不说了,只贴核心配置
启动类org.springframework.cloud spring-cloud-starter-consul-discovery
@SpringBootApplication
@EnableDiscoveryClient //该注解用于向使用consul或者zookeeper作为注册中心时注册服务
public class OrderZKMain80
{
public static void main(String[] args) {
SpringApplication.run(OrderZKMain80.class, args);
}
}
配置文件
cloud:
consul:
host: localhost
port: 8500
discovery:
service-name: ${spring.application.name}
loadbalancer:
ribbon:
enabled: false
Zookeeper
依赖
配置文件org.springframework.cloud spring-cloud-starter-zookeeper-discovery org.apache.zookeeper zookeeper org.apache.zookeeper zookeeper 3.4.9
server:
port: 8004 # 注册到zookeeper服务器的支付服务提供者端口号
spring:
application:
name: cloud-provider-payment
cloud:
zookeeper:
connect-string: localhost:2181 #zookeeper服务的地址
启动类
@SpringBootApplication
@EnableDiscoveryClient //该注解用于向使用consul或者zookeeper作为注册中心时注册服务
public class OrderZKMain80
{
public static void main(String[] args) {
SpringApplication.run(OrderZKMain80.class, args);
}
}



