spring boot 添加客户端负载均衡
1.pom.xml文件中,添加依赖包
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-netflix-ribbon</artifactId> </dependency>
2.Application启动类添加注解@LoadBalanced
@Bean
@LoadBalanced public RestTemplate restTemplate() { return builder.build(); }