Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Spring云侧车配置问题_Java_Spring_Spring Cloud - Fatal编程技术网

Java Spring云侧车配置问题

Java Spring云侧车配置问题,java,spring,spring-cloud,Java,Spring,Spring Cloud,我有一个非常简单的sidecar应用程序-只需要所需的注释和主要方法,如下所示: @SpringBootApplication @EnableSidecar public class SidecarApplication { ... } 我还有一个服务在它后面,在同一台主机上,它有一个GET/joke端点 侧车配置: server.port=5678 spring.application.name=joker sidecar.port=8083 sidecar.home-page-u

我有一个非常简单的sidecar应用程序-只需要所需的注释和主要方法,如下所示:

@SpringBootApplication
@EnableSidecar
public class SidecarApplication {
    ...
}
我还有一个服务在它后面,在同一台主机上,它有一个GET/joke端点

侧车配置:

server.port=5678
spring.application.name=joker

sidecar.port=8083
sidecar.home-page-uri=http://localhost:8083/
sidecar.health-uri=http://localhost:8083/health.json

management.security.enabled=false
logging.level.root=DEBUG
zuul.routes.joker.url=http://localhost:8083/
然而,当调用GET时,我得到404。如果我调用GET,我会得到一个有效的响应

现在,如果我将其添加到侧车配置中:

server.port=5678
spring.application.name=joker

sidecar.port=8083
sidecar.home-page-uri=http://localhost:8083/
sidecar.health-uri=http://localhost:8083/health.json

management.security.enabled=false
logging.level.root=DEBUG
zuul.routes.joker.url=http://localhost:8083/
然后调用GET按预期工作


我是否遗漏了什么,或者这是预期的行为?我希望sidecar不需要额外的配置来将所有传入的请求路由到包装好的服务,并且我希望用于访问sidecar后面的服务的url不需要包含服务名称。

我认为您需要在应用程序中使用更多类似的符号。属性:

spring.application.name = joke
server.port = 5678

eureka.client.serviceUrl.defaultZone = http: // localhost: 9000 / eureka
eureka.client.register-with-eureka = true
eureka.client.fetch-registry = true

sidecar.port = 8083
sidecar.health-uri = http: // localhost: 8083 / health

management.security.enabled = false

/ * example * /
zuul.routes.wstore.path = / wstore / **
zuul.routes.wstore.url = http: // localhost: 8083
在应用程序中,应具有这3个符号

@SpringBootApplication
@EnableSidecar
@EnableDiscoveryClient
public class SidecarApplication {...}

注意:此配置对于spring boot 1.5.6非常有用。如果您使用的是
Eureka
yes,则路由是透明的。
sidecar
应用程序向
Eureka
注册自身,但将Eureka
InstanceInfo
对象的
homePageUrl
值设置为微服务的实际主机和端口。这是您的客户端将用于调用您的微服务的值。

zuul作为网关api,这似乎是预期的行为。我们最终使用的是我在问题中描述的,以及georges在对原始问题的评论中确认的@EnableDiscoveryClient没有帮助,除非在sidecar配置中有从URL模式到服务ID的显式映射。很抱歉这么说,但是关于配置和原始问题的任何其他内容都只是噪音。