我有一个非常简单的sidecar应用程序--只需要注释和main方法,如下所示:
@SpringBootApplication
@EnableSidecar
public class SidecarApplication {
...
}在同一主机上,我还有一个位于它后面的服务,它有一个GET /joke端点。
sidecar配置:
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但是,当调用GET http://localhost:5678/joke时,我得到404。如果我调用GET http://localhost:8083/joke,我会得到一个有效的响应。
现在,如果我将这个添加到sidecar配置中:
zuul.routes.joker.url=http://localhost:8083/然后,调用GET http://localhost:5678/joker/joke就会按照预期工作。
我是否遗漏了什么,或者这是意料之中的行为?我原本希望sidecar不需要额外的配置就可以将所有传入的请求路由到封装的服务,并且我希望url用于访问sidecar后面的服务,而不需要包含服务名称。
发布于 2018-07-31 04:42:54
我认为在application.properties中需要更多这样的符号:
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.RELEASE很有用
发布于 2021-02-18 22:54:48
如果您使用的是Eureka,则路由是透明的。sidecar应用程序向Eureka注册自身,但将Eureka InstanceInfo对象的homePageUrl值设置为微服务的实际主机和端口。这是您的客户端将用来调用您的微服务的值。
https://stackoverflow.com/questions/46203791
复制相似问题