【发布时间】:2017-05-18 22:07:21
【问题描述】:
问题:
我在Bluemix 的 Api Connect 中发布了两个微服务(在 Spring Boot 中)。我想为每个人分配一个基本路径,以便我们有办法将它们分开。即:
API 1 的路径:https://api.us.apiconnect.ibmcloud.com/[organization]/[catalog]/api1/[endpoint-of-api1]
API 2 的路径:https://api.us.apiconnect.ibmcloud.com/[organization]/[catalog]/api2/[endpoint-of-api2]
我的解决方案:
在其 application.yml 文件中为每个 Api 分配上下文路径:
server:
contextPath: /api1
即使这样可行,但为整个服务器设置基本路径似乎并不正确,因为微服务不应该知道它的外部上下文(基本路径的原因只是为了在API 连接)
有什么想法吗?
【问题讨论】:
-
@RobertoParedes:上述 SO 问题是否有助于解决您的问题,还是您仍需要帮助?
-
@JoshuaAlger 不,这实际上是我现在拥有的。我的问题是是否有更好的方法。就像 Api Connect 可以配置它,而不必在应用程序配置中设置它
-
@RobertoParedes:我在下面添加了一个答案以显示更好的方法
-
@JoshuaAlger 不错!我要试试那个解决方案。非常感谢
标签: spring-boot ibm-cloud microservices apiconnect