springcloud-ribbon的使用

在ribbon的springboot project import  dependency jar

<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-ribbon</artifactId>
<version>1.4.0.RELEASE</version>
</dependency>
best select version is 1.4.0
let is look resources configuration file application.yml
#with two client happy
server:
  port: 9000
spring:
  application:
    name: ribbon-consumer
stores:
  ribbon:
    listOfServers: localhost:1001,localhost:1002
    NFLoadBalancerRuleClassName: com.netflix.loadbalancer.RandomRule

the stores is on you dynamic define,and then are fixed。the listOfServers is fixed,the value is the ip and port you repersent。

猜你喜欢

转载自www.cnblogs.com/fuckingPangzi/p/11096401.html