springcloud12---sidecar

Sidecar:异构平台整合。做了一个桥

package com.itmuch.cloud;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.sidecar.EnableSidecar;

@SpringBootApplication
@EnableSidecar
public class SidecarApplication {
  public static void main(String[] args) {
    SpringApplication.run(SidecarApplication.class, args);
  }
}
spring:
  application:
    name: microservice-sidecar
server:
  port: 8070
eureka: #加入到eureka
  client:
    service-url:
      defaultZone: http://user:password123@localhost:8761/eureka
  instance:
    prefer-ip-address: true
sidecar:
  port: 8060     #异构微服务的端口,nodejs服务的端口
  healthUri: http://localhost:8060/aaa.json       #nodejs的直接访问方式
#通过zuul访问sidecar进而访问nodejs的aaa.json接口:http://localhost:8040/microservice-sidecar/aaa.json
#通过zuul访问sidecar进而访问nodejs的首页:  http://localhost:8040/microservice-sidecar
#user和movie微服务之间的调用用http://microservice-sidecar/aaa.json就不用通过zuul了
#zuul查看eureka的代理节点http://localhost:8040/routes : {"/user-path/**":"microservice-provider-user","/microservice-sidecar/**":"microservice-sidecar"}


#sidecar的health:http://localhost:8070/health

#sidecar和异构的应用要配置到同一个host上面去,不在同一个host就要配置eureka.instance.hostName,十个微服务是异构的就要10个sidecar。也可以通过别的方式注册异构系统。


#http://localhost:8070/是sidecar的首页。
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>com.itmuch.cloud</groupId>
        <artifactId>microservice-spring-cloud</artifactId>
        <version>0.0.1-SNAPSHOT</version>
    </parent>

    <artifactId>microservice-sidecar</artifactId>
    <packaging>jar</packaging>

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

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

</project>

猜你喜欢

转载自www.cnblogs.com/yaowen/p/9159022.html
今日推荐