我的zuul应用程序出现问题。说:
The load balancer does not have an available server for the client: HELLO-SERVER
如果我要像下面这样启动我的客户的服务,那么我可以覆盖默认配置文件,因为我有很多配置文件:
我的配置服务器:
java -Xms128m -Xmx128m -jar target/config-local-0.0.1-SNAPSHOT.jar
我的eureka服务器:
java -Xms128m -Xmx128m -jar target/eureka.server.cloud-0.0.1-SNAPSHOT.jar
我的问候服务器:
java -Xms128m -Xmx128m -jar -Dspring.application.name=reporting -Dspring.profiles.active=dev -Dserver.port=3030 target/hello-server-0.0.1-SNAPSHOT.jar
我的Zuul服务:
java -Xms128m -Xmx128m -jar -Dserver.port=5050 target/zuul-service-0.0.1-SNAPSHOT.jar
配置:
我设置了 ConfigServerMicroservice ,其中我的application.yml是这样的:
server:
port: 8191
spring:
profiles:
active:
- native
cloud:
config:
server:
native:
search-locations:
- /home/jhoe/getcare.microservices/config-server-store
management:
endpoints:
web:
exposure:
include:
- '*'
info.app.name: Config Server
info.app.description: Spring Boot Application
info.app.version: 1.0.0
这是我的个人资料:
/home/jhoe/getcare.microservices/config-server-store
membership-dev.yml
membership-prod.yml
membership-qa.yml
membership.yml
reporting-dev.yml
reporting-prod.yml
reporting-qa.yml
reporting.yml
search-dev.yml
search-prod.yml
search-qa.yml
search.yml
这是我的 eureka服务器
package com.eureka.server.cloud;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
@EnableEurekaServer
@SpringBootApplication
public class EurekaServerApplication {
public static void main(String[] args) {
SpringApplication.run(EurekaServerApplication.class, args);
}
}
我的 application.yml (尤里卡服务器)
eureka:
client:
register-with-eureka: false
fetch-registry: false
service-url:
defaultZone: http://localhost:8070/eureka/
waitTimeInMsWhenSyncEmpty: 0
spring.application.name=eureka-service
server.port=8070
我的您好服务器
package com.eureka.server.cloud;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping("/rest/hello/server")
public class HelloResource {
@GetMapping
public String hello() {
return "This is from HELLO-SERVER!";
}
}
bootstrap.yml(Hello服务器)
server:
port: ${PORT:0}
spring:
cloud:
config:
uri:
- http://192.168.2.103:8191
application:
name: membership
profiles:
active:
- dev
application.yml(Hello服务器)
spring:
application:
name: hello-server
server:
port: ${PORT:0}
eureka:
client:
register-with-eureka: true
fetch-registry: true
service-url:
defaultZone: http://localhost:8070/eureka/
healthcheck:
enabled: true
instance:
hostname: localhost
management:
endpoints:
web:
exposure:
include:
- '*'
info.app.name: Hello-Server (Client 2)
info.app.description: Spring Boot Application
info.app.version: 1.0.0
zuul
package eureka.server.cloud;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
@EnableEurekaClient
@EnableZuulProxy
@SpringBootApplication
@EnableDiscoveryClient
public class ZuulServiceApplication {
public static void main(String[] args) {
SpringApplication.run(ZuulServiceApplication.class, args);
}
}
application.yml(zuul)
spring:
application:
name: zuul-service
eureka:
client:
service-url:
defaultZone: http://localhost:8070/eureka/
register-with-eureka: true
fetch-registry: true
instance:
hostname: localhost
server:
port: ${PORT:0}
zuul:
#Service will be mapped under the /api URI
prefix: /api
routes:
hello-server:
path: /server/**
service-id: HELLO-SERVER
hello-client:
path: /client/**
service-id: HELLO-CLIENT
consumer-client:
path: /consumer/**
service-id: CONSUMER-CLIENT
ribbon:
eureka:
enabled: true
ReadTimeout: 60000
#Increase the Hystrix timeout to 60s (for all)
hystrix:
command:
default:
execution:
isolation:
thread:
timeoutInMilliseconds: 180000
在所有这些配置之后,它仍然无法弄清为什么不去我期望的输出:
http://localhost:5050/api/server/rest/hello/server
这是来自HELLO-SERVER!
当我在浏览器中将其踢向个人资料时:
http://localhost:3030/profile
并显示指向的hello服务器配置文件
/home/jhoe/getcare.microservices/config-server-store/reporting-dev.yml
由于该参数:
-Dspring.application.name = reporting -Dspring.profiles.active = dev -Dserver.port = 3030
有什么我想念的吗,非常感谢您的投入,帮助和帮助。