我正在本地计算机上构建微服务。一个客户端应用程序基于netflix-ribbon和netflix-eureka。我在日志中收到以下错误。
com.netflix.client.ClientException:负载均衡器没有适用于客户端的服务器:currency-exchange-service 在com.netflix.loadbalancer.LoadBalancerContext.getServerFromLoadBalancer(LoadBalancerContext.java:483)〜[ribbon-loadbalancer-2.3.0.jar:2.3.0] 在com.netflix.loadbalancer.reactive.LoadBalancerCommand $ 1.call(LoadBalancerCommand.java:184)〜[ribbon-loadbalancer-2.3.0.jar:2.3.0] 在com.netflix.loadbalancer.reactive.LoadBalancerCommand $ 1.call(LoadBalancerCommand.java:180)〜[ribbon-loadbalancer-2.3.0.jar:2.3.0] 在rx.Observable.unsafeSubscribe(Observable.java:10327)〜[rxjava-1.3.8.jar:1.3.8]
要解决此问题,我必须删除以下依赖项,然后该服务才能正常运行。
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.4.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com.sudip.mircoservices</groupId>
<artifactId>currency-calculation-service</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>currency-calculation-service</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>Greenwich.SR1</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
<version>2.0.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
<version>2.0.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
<version>2.0.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
我想将此(考虑服务A)注册为Eureka中的服务,并在服务A中进行负载平衡,该服务将在运行的3个实例中调用一个实例(服务B)。