SpringCloud (제 027 편) 는 이 구조 마이크로 서비스 시스템 을 SpringCloud 생태 권 에 통합 시 켰 다 (예 를 들 어 nodejs 마이크로 서비스 통합).

6397 단어
SpringCloud (제 027 편) 는 이 구조 마이크로 서비스 시스템 을 SpringCloud 생태 권 에 통합 시 켰 다 (예 를 들 어 nodejs 마이크로 서비스 통합).

  • 대체로
    1、           ,             ,                ,                     ;
    2、      ,SpringCloud                   ,   sidecar                          ;
    3、                                   ;
    

    2. 실현 절차
    2.1 maven 인용 팩 추가
    
    
        4.0.0
    
        springms-sidecar
        1.0-SNAPSHOT
        jar
    
        
            com.springms.cloud
            springms-spring-cloud
            1.0-SNAPSHOT
        
    
        
            
            
                org.springframework.cloud
                spring-cloud-netflix-sidecar
            
    
            
            
                org.springframework.cloud
                spring-cloud-starter-eureka
            
        
    
    
    

    2.2 응용 프로필 추가 (springms - sidecar \ src \ main \ resources \ \ application. yml)
    spring:
      application:
        name: springms-sidecar
    server:
      port: 8210
    eureka:
      datacenter: SpringCloud   #    http://localhost:8761    Eureka      System Status   Data center     
      environment: Test         #    http://localhost:8761    Eureka      System Status   Environment     
      client:
        service-url:
          defaultZone: http://admin:admin@localhost:8761/eureka
        healthcheck:  #     
          enabled: true
      instance:
        prefer-ip-address: true
        instance-id: ${spring.application.name}:${spring.cloud.client.ipAddress}:${spring.application.instance_id:${server.port}}
    
    
    
    #####################################################################################################
    #     
    logging:
      level:
        root: INFO
        com.springms: DEBUG
    #####################################################################################################
    
    
    
    
    
    #####################################################################################################
    #         , port           ;health-uri               
    sidecar:
      port: 8205
      health-uri: http://localhost:8205/health.json
    #####################################################################################################
    
    

    2.3 sidecar 마이크로 서비스 시작 클래스 추가 (springms - sidecar \ src \ main \ java \ com \ springms \ \ cloud \ MsSideCarapplication. java)
    package com.springms.cloud;
    
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.cloud.netflix.sidecar.EnableSidecar;
    
    /**
     *            SpringCloud     (     nodejs    )。
     *
     *    EnableSidecar        eureka    ,          eureka       ,  EnableZuulProxy        。
     *
     * @EnableSidecar --> { @EnableCircuitBreaker、@EnableDiscoveryClient、@EnableZuulProxy }     eureka      ,       Hystrix        ,     zuul API    。
     *
     * @author hmilyylimh
     *
     * @version 0.0.1
     *
     * @date 2017/9/28
     *
     */
    @SpringBootApplication
    @EnableSidecar
    public class MsSideCarApplication {
    
        public static void main(String[] args) {
            SpringApplication.run(MsSideCarApplication.class, args);
            System.out.println("【【【【【【 SideCar     】】】】】】   .");
        }
    }
    

    테스트
    /****************************************************************************************
      、           SpringCloud     (     nodejs    )(      ):
    
     1、   application.yml   ,          EnableSidecar   ;
     2、   springms-discovery-eureka     ,  1   ;
     3、   springms-gateway-zuul-fallback     ,  1   ;
     4、   springms-sidecar     ,  1   ;
     5、   springms-node-service    ,  1   ;
    
     6、      ,   http://localhost:8205/           "            nodejs     "        ;
     7、      ,     http://localhost:8205/health.json,          "{"status":"UP"}"        ;
    
        :nodejs    ,           ;
    
     8、      ,   http://localhost:8200/springms-sidecar/           "            nodejs     "        ;
     9、      ,     http://localhost:8200/springms-sidecar/health.json,          "{"status":"UP"}"        ;
    
        :   yml        sidecar   ,           SpringCloud    ,      ;
     ****************************************************************************************/
    
    /****************************************************************************************
      、           SpringCloud     (     nodejs    )(          ,    Ribbon        ):
    
     1、   application.yml   ,          EnableSidecar   ;
     2、   springms-discovery-eureka     ,  1   ;
     3、   springms-gateway-zuul-fallback     ,  1   ;
     4、   springms-sidecar     ,  1   ;
     5、   springms-consumer-movie-ribbon     ,  1   ;
     6、   springms-node-service    ,  1   ;
    
     7、      ,   http://localhost:8205/           "            nodejs     "        ;
     8、      ,     http://localhost:8205/health.json           "{"status":"UP"}"        ;
    
        :nodejs    ,           ;
    
     9、      ,   http://localhost:8200/springms-sidecar/           "            nodejs     "        ;
     10、      ,     http://localhost:8200/springms-sidecar/health.json           "{"status":"UP"}"        ;
    
        :   Zuul     ,      ,     zuul          ;
    
     11、      ,   http://localhost:8010/sidecar/           "            nodejs     "        ;
     12、      ,     http://localhost:8010/sidecar/health.json           "{"status":"UP"}"        ;
    
        :  springms-consumer-movie-ribbon          ,            ,     SpringCloud             ;
     ****************************************************************************************/
    

    다운로드 주소
    https://gitee.com/ylimhhmily/SpringCloudTutorial.git
    SpringCloudTutorial 교류 QQ 군: 23532242
    SpringCloudTutorial 커 뮤 니 케 이 션 위 챗 그룹: 위 챗 커 뮤 니 케 이 션 그룹 QR 코드 이미지 링크
    관심 을 환영 합 니 다. 당신 의 것 은 틀림없이 저 에 대한 가장 큰 지지 입 니 다!!
  • 좋은 웹페이지 즐겨찾기