如何使用Spring Cloud和Netflix的Eureka注册Node应用程序
我试图用Netflix的Eureka注册我的节点应用程序,并且经过Googlesearch之后,我仍然在寻找解决scheme。 最大我可以找出是我们有普拉那,但我有一个问题,仍然在Prana的问题列表 (我猜这意味着我的REST模板是无法发现这个应用程序)。
Sidecar ,是另一个build议的解决scheme,对此我没有得到任何回应。 除了这两个我已经find了一个节点模块尤里卡节点客户端 ,但没有一个服务于我的目的。
您可以创build一个Sidecar
应用程序,就像创build任何一个spring-boot
应用程序一样:
@EnableSidecar @SpringBootApplication public class SideCarApplication { public static void main(final String[] args) { SpringApplication.run(SideCarApplication.class, args); } }
重要的是,您必须configuration它才能正确注册您的实际服务。 你的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
重要的是要注意,健康点应该返回,以便您在尤里卡的服务状态正确。 返回的健康服务json:
{ "status":"UP" }
如果您在设置spring-boot
应用程序时遇到问题,请使用https://start.spring.io/来configuration项目。 可悲的是,没有边车的select,但你会明白这一点。 你可以从STS
(Spring Tool Suite)中做同样的事情。
Sidecar
的Maven依赖项(以spring-cloud作为父项):
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-netflix-sidecar</artifactId> </dependency>
我使用npm generator-express-sidecar生成了一个带有所有开箱即用configuration的gradlew sidecar项目请参考下面共享的参考链接https://www.npmjs.com/package/generator-express-sidecar