SpringCloud version: 3.0.2
删除spring-cloud-starter-netflix-ribbon依赖
spring-cloud-starter-netflix-eureka-client 3.0版本的已经内置ribbon,再导入的spring-cloud-starter-netflix-ribbon可能会产生冲突
RestTemplate的Bean加入@LoadBalanced注解
@Bean
@LoadBalanced
public RestTemplate restTemplate() {
return new RestTemplate();
}
消费者的配置文件中没有加入注册中心的地址
eureka:
client:
service-url:
defaultZone: http://localhost:8888/eureka/
fetch-registry: true
server:
port: 8881
spring:
application:
name: service-ribbon
pom.xml添加ribbon-eureka依赖
<dependency>
<groupId>com.netflix.ribbon</groupId>
<artifactId>ribbon-eureka</artifactId>
<version>2.7.18</version>
</dependency>
网友评论