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(); }