sidecar异构微服务

2019-08-03  本文已影响0人  爱上游戏开发

0、理解

通过sidecar将异构平台的微服务注册到Eureka;让其和SpringCloud的生态空间连在一起;

1、使用

pom.xml`

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-netflix-sidecar</artifactId>
</dependency>

application.yml

spring:
  application:
    name: microservice-sidecar
server:
  port: 8070
eureka: 
  client: 
    service-url:
      defaultZone: http://localhost:8761/eureka
  instance:
    prefer-ip-address: true
sidecar:
  port: 8060
  health-uri: http://localhost:8060/health.json
   

启动类SidecarApplication.java

@SpringBootApplication
//注册Sidecar;@EnableSidecar是一个组合注解
@EnableSidecar
public class SidecarApplication {
    public static void main(String[] args) {
        System.out.println("Hello Zuul!");
        SpringApplication.run(SidecarApplication.class, args);
    }
}

注意

上一篇 下一篇

猜你喜欢

热点阅读