1、负载均衡未生效,即@LoadBalanced这个注释未生效

  1. @LoadBalanced
  2. @Bean
  3. public RestTemplate restTemplate() {
  4. return new RestTemplate();
  5. }
  • 添加依赖包
    1. <!-- 负载均衡-->
    2. <dependency>
    3. <groupId>org.springframework.cloud</groupId>
    4. <artifactId>spring-cloud-starter-loadbalancer</artifactId>
    5. </dependency>
    2、bootstrap.yml没有生效,添加依赖包 (暂未遇到)
    1. <!-- bootstrap -->
    2. <dependency>
    3. <groupId>org.springframework.cloud</groupId>
    4. <artifactId>spring-cloud-starter-bootstrap</artifactId>
    5. </dependency>