1.Spring Cloud - Netflix官网例子
http://cloud.spring.io/spring-cloud-netflix/
1)代码,基本是官网copy下来
https://git.coding.net/JackHuang0801/project.git
2)启动命令mvn spring-boot:run
服务端面板
客户端请求结果
2)代码分析
application.yml配置如下
server.port配置了tomcat的启动端口,eureka实例的名字,以及eureka其他配置。因为我们这里是eureka服务端,
register-with-eureka配置为false,这个配置表示是否将其本身注册到eureka server以被其他发现
fetch-registry配置为false,这个配置表示是否需要从eureka server中抓取eureka上的注册信息
defaultZone 默认地址为
http://localhost:8761/eureak
server:
port: 8761
eureka:
client:
registerWithEureka: false
fetchRegistry: false
server:
waitTimeInMsWhenSyncEmpty: 0
bootstrap.yml配置如下,这里只配置了服务的名字叫 eureka
spring:
application:
name: eureka
cloud:
config:
uri: ${CONFIG_SERVER_URL:http://localhost:8888}
2017-Netflix_Client 也可以配置这两个文件,也可以用默认
2.Spring Cloud - Netflix基于官网例子改写
看第二篇文章服务消费者加入ribbon负载均衡器