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 코드 이미지 링크
관심 을 환영 합 니 다. 당신 의 것 은 틀림없이 저 에 대한 가장 큰 지지 입 니 다!!
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
다양한 언어의 JSONJSON은 Javascript 표기법을 사용하여 데이터 구조를 레이아웃하는 데이터 형식입니다. 그러나 Javascript가 코드에서 이러한 구조를 나타낼 수 있는 유일한 언어는 아닙니다. 저는 일반적으로 '객체'{}...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.