负载平衡器没有可用于客户端的服务器:会议
当我尝试通过 Zuul 网关访问服务时,Zuul 无法将请求转发到相应的服务。以下错误是我面临的:meeting
- nettflix.zuul.exception.ZuulException: Forwarding error
- 由以下原因导致:com.netflix.client.ClientException: Load Balancer 没有可用于客户端的服务器:会议
让我分享一下服务的 application.yml,eureka 和 zuul gateway。
尤里卡客户:
Application.yml
server:
port: 8761
eureka:
instance:
hostname: localhost
lease-renewal-interval-in-seconds: 300
client:
register-with-eureka: false
fetch-registry: true
serviceUrl:
defaultZone: http://localhost:8761/eureka/
ZuulGateWay:
application.yml
server:
port: 8085
spring:
application:
name: gatekeeper
zuul:
routes:
meeting: /meeting/**
serviceId: meeting
ribbon:
eureka:
enabled: false
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8761/eureka/
ZuulGateWay: SpringBootApplication
package com.sagarp.gatekeeper;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
@SpringBootApplication
@EnableEurekaClient
@EnableZuulProxy
public class MeetingApplication {
public static void main(String[] args) {
SpringApplication.run(MeetingApplication.class, args);
}
}
我的服务类(会议): Application.yml
server:
port: 0
spring:
application:
name: meeting
datasource:
url: jdbc:mysql://localhost:3306/sagarp?useSSL=false
username: myUserName
password: myPassWord
jpa:
properties:
hibernate:
dialect: org.hibernate.dialect.MySQL5InnoDBDialect
hibernate:
ddl-auto: update
eureka:
client:
registerWithEureka: true
fetchRegistry: true
serviceUrl:
defaultZone: http://localhost:8761/eureka/
instance:
lease-renewal-interval-in-seconds: 5
我的服务类(会议): SpringBootApplication
package com.sagarp;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
@SpringBootApplication
@EnableEurekaClient
public class MeetingApplication {
public static void main(String[] args) {
SpringApplication.run(MeetingApplication.class, args);
}
}
如您所见,该配置可确保 eureka 客户端发现我的所有服务。
在eureka控制台中,我已经验证了相同的内容,并且两者都可见。zuul gateway
my service(meeting)
为了更好的视图,你可以访问我的git存储库。https://github.com/sagar-patro/demo-microservices
任何帮助都会非常明显