pra*_*jha 8 node.js spring-cloud netflix-eureka aws-api-gateway
我正在努力注册我的节点应用程序,使用Netflix的Eureka,在谷歌搜索后,我仍在寻找解决方案.我能想到的最大值是我们有Prana但是我遇到的问题仍然在Prana的问题列表中(我猜这意味着我的REST模板无法发现这个应用程序).
Sidecar,是另一个建议的解决方案,我没有得到任何回应.除了这两个,我找到了一个节点模块Eureka-Node-client,但它们都没有达到我的目的.
您可以Sidecar像创建任何spring-boot应用程序一样创建应用程序:
@EnableSidecar
@SpringBootApplication
public class SideCarApplication {
public static void main(final String[] args) {
SpringApplication.run(SideCarApplication.class, args);
}
}
Run Code Online (Sandbox Code Playgroud)
重要的是你必须配置它才能正确注册你的实际服务.你application.yml应该看起来像这样:
server:
port: 9999 -- the port your spring-boot sidecar is running
spring:
application:
name: nodeapplication -- the name will be your id in eureka
sidecar:
port: 8000 -- the node applications port
health-uri: http://localhost:8000/health.json -- the exposed health eindpoint of your node application
Run Code Online (Sandbox Code Playgroud)
重要的是要注意健康点应该返回,UP以便您的服务状态在尤里卡是正确的.返回的json用于健康服务:
{
"status":"UP"
}
Run Code Online (Sandbox Code Playgroud)
如果您在设置spring-boot应用时遇到问题,请使用https://start.spring.io/配置项目.可悲的是,没有一个边车选项可以打勾,但你会得到这个想法.您可以从STS(Spring Tool Suite)执行相同的操作.
maven依赖Sidecar(以spring-cloud为父):
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-netflix-sidecar</artifactId>
</dependency>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3668 次 |
| 最近记录: |