[Spring Cloud] - 1. Configuration Server ๊ตฌ์„ฑ

๋ฐ˜์‘ํ˜•

์ง€๋‚œ ๊ธ€์—์„œ MSA(Micro Service Architecture)์— ๋Œ€ํ•œ ๊ธฐ๋ณธ์ ์ธ ๋‚ด์šฉ์— ๋Œ€ํ•ด์„œ ์•Œ์•„๋ดค์—ˆ๋Š”๋ฐ์š”. ํ˜น์‹œ๋ผ๋„ ์ด ๊ธ€์„ ์ฝ์–ด๋ณด์ง€ ๋ชปํ–ˆ๋‹ค๋ฉด, ์•„๋ž˜์˜ ๋งํฌ๋ฅผ ํ†ตํ•ด์„œ ์ง์ ‘ ์ฝ์–ด๋ณด์‹ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 

MSA (Micro Service Architecture) ๋ž€ ๋ฌด์—‡์ผ๊นŒ?

์•ˆ๋…•ํ•˜์„ธ์š”. ์˜ค๋Š˜์€ Micro Service Architecture์— ๋Œ€ํ•ด ์ด์•ผ๊ธฐ ํ•ด๋ณด๊ณ ์ž ํ•ฉ๋‹ˆ๋‹ค. ํ•œ๋™์•ˆ MSA๊ฐ€ ๊ต‰์žฅํžˆ ํ™”๋‘์˜€๋Š”๋ฐ, ์š”์ฆ˜์€ ๋ถ„์œ„๊ธฐ๊ฐ€ ์‹์–ด์ง€๋Š” ๋“ฏํ•˜์—ฌ ์˜ค๋Š˜ ๋ธ”๋กœ๊ทธ์— ์ด ๊ธ€์„ ์ ๊ฒŒ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ์šฐ๋ฆฌ๋Š” ๋ฐฑ์—”๋“œ ๊ฐœ๋ฐœ..

blog.neonkid.xyz

์ด๋ฒˆ ํŒŒํŠธ์—์„œ๋Š” Java ์–ธ์–ด์˜ ์›น ๊ฐœ๋ฐœ ํ”„๋ ˆ์ž„์›Œํฌ์ธ Spring์„ ์ด์šฉํ•ด์„œ ์ด Micro Service Architecture๋ฅผ ๊ตฌ์„ฑํ•˜๋Š” ์‹œ๊ฐ„์„ ๊ฐ€์ ธ๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค. ๊ทธ ์ฒซ ๋ฒˆ์งธ๋Š” ๋ฐ”๋กœ Configuration Server๋ฅผ ๊ตฌ์„ฑํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค.

 

Configuration Server์˜ ํ•„์š”์„ฑ

์›น ์„œ๋ฒ„๋ฅผ ๊ฐœ๋ฐœํ•  ๋•Œ ์šฐ๋ฆฌ๋Š” ์ด ์„œ๋ฒ„์˜ ํŒŒ๋ผ๋ฏธํ„ฐ๋ฅผ ์ฃผ๊ธฐ ์œ„ํ•ด์„œ Configuration์„ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค. Spring์˜ ๊ฒฝ์šฐ, application.properties ํŒŒ์ผ์„, Flask์—์„œ๋Š” env.py, Node.js์—์„œ๋Š” package.json ๋“ฑ์„ ์ด์šฉํ•˜๋Š” ๊ฒƒ์ด์ฃ .

๊ทธ๋Ÿฐ๋ฐ, Micro Service Architecture๋ฅผ ๊ตฌ์„ฑํ•˜๋ ค๋‹ˆ Configuration Server๋ฅผ ๊ตฌ์„ฑํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์šฐ๋ฆฌ๊ฐ€ MSA๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ์ด์œ ๋Š” ์„œ๋น„์Šค๋ฅผ ๋ถ„์‚ฐํ•˜๋Š” ๋ฐ ์žˆ์Šต๋‹ˆ๋‹ค. ๋น„์ฆˆ๋‹ˆ์Šค ๋กœ์ง์„ ํ•œ ์„œ๋ฒ„์— ๋ชฐ์•„๋‹ด์ง€ ์•Š๊ณ , ๊ธฐ๋Šฅ๋งˆ๋‹ค ์ชผ๊ฐœ์–ด ์„œ๋ฒ„๋ฅผ ๊ฐœ๋ฐœํ•˜๊ธฐ ๋•Œ๋ฌธ์— ๊ทธ์— ๋”ฐ๋ฅธ ํ™˜๊ฒฝ๋„ ๋‹ค ์ œ๊ฐ๊ฐ์ผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

ํ•˜์ง€๋งŒ ์„œ๋ฒ„๋ฅผ ํ•œ ๊ฐœ ๊ฐœ๋ฐœํ•  ๋•Œ๋Š” Config๋ฅผ ํ•œ ๊ฐœ๋งŒ ์„ค์ •ํ•˜๋ฉด ๋˜์ง€๋งŒ ์„œ๋น„์Šค ๋‹จ์œ„๋กœ ์ชผ๊ฐœ์–ด ๊ฐœ๋ฐœํ•  ๊ฒฝ์šฐ์—๋Š” ๊ทธ ์„ค์ •๋“ค์„ ์ผ์ผ์ด ํ•˜๋‚˜์”ฉ ๋‹ค ์žก์•„์ค˜์•ผ ํ•ฉ๋‹ˆ๋‹ค. ๊ต‰์žฅํžˆ ๋ถˆํŽธํ•œ ์ผ์ด์ฃ .

๊ทธ๋ž˜์„œ ์šฐ๋ฆฌ๋Š” Configuration Server๋ฅผ ์„ค์ •ํ•  ํ•„์š”๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. ๊ฐ ์„œ๋น„์Šค๋ณ„๋กœ ์„ค์ •์„ ๋‹ค๋ฅด๊ฒŒ ์ฃผ์–ด์ฃผ๋Š” ๊ฒƒ์€ ๊ทธ๋ฆฌ ์–ด๋ ค์šด ์ผ์€ ์•„๋‹ˆ์ง€๋งŒ ์ด๋“ค์„ ์„œ๋ฒ„๋ณ„๋กœ ๊ฐœ๋ฐœ์ž๊ฐ€ ์ผ์ผ์ด ์†์œผ๋กœ ์ฃผ์–ด์ฃผ๋Š” ๊ฒƒ์€ ์†์ด ๋งŽ์ด ํ•„์š”ํ•ฉ๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ Configuration Server๋ฅผ ๊ตฌ์ถ•ํ•˜์—ฌ ๊ฐ WAS์—์„œ ์ด๋ฅผ Pull ํ•˜๋„๋ก ๊ตฌ์ถ•ํ•˜๋Š” ๊ฒƒ์ด์ฃ .

Spring Cloud Configuration Example

๊ทธ๋ฆผ์œผ๋กœ ๋ณด์ž๋ฉด ์œ„์™€ ๊ฐ™์€ ๊ตฌ์„ฑ์ด ๋ฉ๋‹ˆ๋‹ค. ๋ฉ”๋ชจ์žฅ๊ณผ ๊ฐ™์€ ๋…ธํŠธ ์„œ๋น„์Šค๋ฅผ ๊ฐœ๋ฐœํ•œ๋‹ค๊ณ  ๊ฐ€์ •ํ–ˆ์„ ๋•Œ ๊ฐ€์žฅ ๊ฐ„๋‹จํ•˜๊ฒŒ ๊ตฌ์„ฑํ•  ์ˆ˜ ์žˆ๋Š” ๋น„์ฆˆ๋‹ˆ์Šค ๋กœ์ง์œผ๋กœ ํšŒ์›(Member)๊ณผ Note(๋ฉ”๋ชจ)๋ฅผ ๊ตฌ์„ฑํ•œ ๊ฒƒ์ž…๋‹ˆ๋‹ค. ๊ฐ ์„œ๋น„์Šค๋ณ„๋กœ ์›น ์„œ๋น„์Šค๋ฅผ ๋ณ„๋„๋กœ ๊ฐœ๋ฐœํ•˜์˜€์„ ๋•Œ, ๊ฐ ์„ค์ •์€ Configuration Server์—์„œ ๋ฐ›๋Š” ๋ฐฉ์‹์ธ ๊ฒƒ์ด์ฃ .

์ด๋ ‡๊ฒŒ ๊ตฌ์„ฑํ•ด์„œ ์–ป์„ ์ˆ˜ ์žˆ๋Š” ๋˜ ๋‹ค๋ฅธ ์ด์ ์œผ๋กœ๋Š” ์„œ๋ฒ„์˜ ์ค‘๋‹จ์—†์ด ์„ค์ •์„ ๋ฐ”๊ฟ€ ์ˆ˜ ์žˆ๋‹ค๋Š” ์ ์ž…๋‹ˆ๋‹ค. Tomcat์ด๋‚˜ JBoss ๋“ฑ์œผ๋กœ WAS๋ฅผ ์šด์˜ํ•ด๋ณด์‹  ๋ถ„๋“ค์€ ๋Š๋ผ์‹œ๋Š” ๊ฒƒ์ด์ง€๋งŒ ์„œ๋ฒ„์˜ ๊ตฌ์„ฑ์ด ๋ณ€๊ฒฝ๋˜๋ฉด ์„œ๋น„์Šค๊ฐ€ ์ค‘๋‹จ๋œ ์ƒํƒœ๋กœ ์žฌ์‹œ์ž‘์ด ๋ฉ๋‹ˆ๋‹ค. ์„œ๋น„์Šค์˜ ๋ฆฌ์Šคํฌ๊ฐ€ ๊ต‰์žฅํžˆ ํฌ๋‹ค๋Š” ๋‹จ์ ๊ณผ ํ•จ๊ป˜ ๊ณค๋ž€ํ•œ ๋ฌธ์ œ ์ค‘ ํ•œ ๊ฐ€์ง€์ž…๋‹ˆ๋‹ค.

 

Configuration Server ๋งŒ๋“ค๊ธฐ

์–ด๋–ป๊ฒŒ ๊ตฌ๋™๋˜๋Š”์ง€ ๊ตฌ์กฐ๋ฅผ ์•Œ์•˜์œผ๋‹ˆ ์ด์ œ ์ง์ ‘ ๋งŒ๋“ค์–ด๋ณด๋Š” ์‹œ๊ฐ„์„ ๊ฐ€์ ธ๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค. ์ด ๊ธ€์—์„œ๋Š” ์•„๋ž˜์˜ ํˆด์„ ์‚ฌ์šฉํ•  ๊ฒƒ์ž„์„ ์•Œ๋ ค๋“œ๋ฆฝ๋‹ˆ๋‹ค.

- JetBrains IntelliJ IDEA
- Java 1.8.0
- Gradle

์ฃผ๋กœ ์ œ๊ฐ€ ์‚ฌ์šฉํ•˜๋Š” ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด์™€ IDE ๋„๊ตฌ, ๋นŒ๋“œ ๋„๊ตฌ๋ฅผ ์„ ํƒํ•˜์˜€์Šต๋‹ˆ๋‹ค. 

ext {
    set('springCloudVersion', 'Hoxton.SR1')
}

dependencies {
    implementation 'org.springframework.cloud:spring-cloud-config-server'
    testImplementation('org.springframework.boot:spring-boot-starter-test') {
        exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
    }
}

dependencyManagement {
    imports {
        mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
    }
}

build.gradle์—์„œ Spring Cloud Config Server์˜ ํŒจํ‚ค์ง€๋ฅผ ๋ฐ›์„ ์ˆ˜ ์žˆ๋„๋ก ์œ„์™€ ๊ฐ™์€ ์„ค์ •์„ ์ถ”๊ฐ€ํ•ฉ๋‹ˆ๋‹ค.

package xyz.neonkid.configserver;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.config.server.EnableConfigServer;

@EnableConfigServer
@SpringBootApplication
public class ConfigServerApplication {
    public static void main(String[] args) {
        SpringApplication.run(ConfigServerApplication.class, args);
    }
}

๊ทธ๋Ÿฌ๊ณ  ๋‚œ ๋’ค, EnableConfigServer ์–ด๋…ธํ…Œ์ด์…˜๋งŒ ๋ถ™์—ฌ์ฃผ๋ฉด ๊ธฐ๋ณธ์ ์ธ ๊ตฌ์„ฑ ์„œ๋ฒ„์˜ ํ‹€์€ ์™„์„ฑ์ž…๋‹ˆ๋‹ค. 

# Configuration Server ๊ธฐ๋ณธ ์„ค์ •๊ณผ ํ”„๋กœํŒŒ์ผ
server:
  port: 9000
spring:
  profiles:
    active: native, local

resources/bootstrap.yml

์ด์ œ ์ด ์„œ๋ฒ„๊ฐ€ ์–ด๋Š ํฌํŠธ๋ฅผ ์‚ฌ์šฉํ• ์ง€, ๊ทธ๋ฆฌ๊ณ , ๊ธฐ๋ณธ์ ์œผ๋กœ ์–ด๋””์— ์žˆ๋Š” ๊ตฌ์„ฑ ํŒŒ์ผ์„ ์ฝ์„์ง€๋ฅผ ์„ค์ •ํ•ด์ค๋‹ˆ๋‹ค. ๋ณ„๋„์˜ ํŒŒ๋ผ๋ฏธํ„ฐ๊ฐ€ ์—†์„ ๊ฒฝ์šฐ์—๋Š” ์„œ๋ฒ„ ์ž์‹ ์˜ ํŒŒ์ผ์„ ์ฝ๋„๋ก ๋จผ์ € ๊ตฌ์„ฑํ•ด์ค๋‹ˆ๋‹ค.

# ๋กœ์ปฌ ํŒŒ์ผ์„ ์‚ฌ์šฉํ•  ๋•Œ์˜ ์ฝ์„ ํŒŒ์ผ์˜ ๊ฒฝ๋กœ.
spring:
  profiles: local
  cloud:
    config:
      server:
        native:
          search-locations: classpath:/server-configs

resources/bootstrap-local.yml

search-locations๊ฐ€ ๋ฐ”๋กœ ์„ค์ • ํŒŒ์ผ๋“ค์ด ์žˆ๋Š” ๊ฒฝ๋กœ๋ฅผ ๊ฐ€๋ฆฌํ‚ต๋‹ˆ๋‹ค. ์ด ๊ฒฝ๋กœ๋Š” Java์˜ Package ๊ฒฝ๋กœ, JVM์—์„œ ์‚ฌ์šฉํ•˜๋Š” ํ™˜๊ฒฝ ๋ณ€์ˆ˜ ๋ชจ๋‘ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์˜ˆ์‹œ๋ฅผ ๋ช‡ ๊ฐœ ๋“ค์–ด๋ณด๋ฉด..

* OS X / Linux
   - file://${user.home}/server-configs

* Windows
   - file:///${user.home}/server-configs

์ด๋ ‡๊ฒŒ๋„ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ๊ฒƒ์ด์ฃ . ๋งŒ์•ฝ ์„œ๋ฒ„ ๋‚ด์— ๊ตฌ์„ฑ ํŒŒ์ผ์„ ์„ค์ •ํ•˜๊ธฐ ๊นŒ๋‹ค๋กœ์›Œ์„œ ์‹ฌ๋ณผ๋ฆญ ๋งํฌ๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๋“ฑ์˜ ๋ฐฉ๋ฒ•๋„ ์žˆ๊ฒ ์ง€๋งŒ ๊ฐ€๋Šฅํ•œ ์œ„์˜ ๋ฐฉ๋ฒ•์„ ์“ฐ๋Š” ๊ฒƒ์ด ํ˜„๋ช…ํ•ฉ๋‹ˆ๋‹ค.

 

Config์„ Configuration ์„œ๋ฒ„์™€ ๋ถ™์ด๊ธฐ

์ด์ œ ๊ตฌ์„ฑ ์„œ๋ฒ„๋„ ์™„์„ฑ๋˜์—ˆ์œผ๋‹ˆ ๊ฐ ์„œ๋น„์Šค๋ณ„๋กœ ์„ค์ •์„ ๊ตฌ์„ฑํ•˜๊ณ , ์ด๋ฅผ ์„œ๋ฒ„์—์„œ ๋™๊ธฐํ™” ํ•  ์ˆ˜ ์žˆ๋„๋ก ๊ตฌ์„ฑํ•ด๋ด…์‹œ๋‹ค. ์œ„์—์„œ ์šฐ๋ฆฌ๋Š” ๋กœ์ปฌ ํ™˜๊ฒฝ์— ์žˆ๋Š” ํ™˜๊ฒฝ ์„ค์ •์„ ๋ถˆ๋Ÿฌ์™€์„œ ๋™๊ธฐํ™” ์‹œํ‚ค๋Š” ๋ฐฉ๋ฒ•์„ ์„ ํƒํ–ˆ์œผ๋ฏ€๋กœ ์ด ๋ฐฉ๋ฒ•์„ ๊ทธ๋Œ€๋กœ ์‚ฌ์šฉํ•ด๋ณด๋„๋ก ํ•˜์ฃ .

spring:
    profiles: dev
    message: Loaded MemberService for Development Mode..

server-configs/member-service-dev.properties

๋จผ์ € ํšŒ์› ์„œ๋น„์Šค์— ๋Œ€ํ•œ ๊ฐœ๋ฐœ ์„œ๋ฒ„์˜ ๊ตฌ์„ฑ ์„ค์ •์„ ๋‚˜ํƒ€๋‚ธ ๊ฒƒ์ž…๋‹ˆ๋‹ค. ๋ฐ˜๋Œ€๋กœ ๋ฐฐํฌ/์šด์˜ ์„œ๋ฒ„์˜ ๊ฒฝ์šฐ, profiles๋งŒ ๋‹ค๋ฅด๊ฒŒ ์ฃผ๊ณ  ์„ค์ •ํ•  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค.

spring:
    profiles: prod
    message: Loaded MemberService for Production Mode...

server-configs/member-service-prod.properties

์Œ... ๊ทธ๋Ÿฐ๋ฐ, ์šฐ๋ฆฌ๊ฐ€ ๊ธฐ๋ณธ์ ์œผ๋กœ Spring Boot 2.0์„ ์‚ฌ์šฉํ•˜์—ฌ ์ง์ ‘ ์„œ๋ฒ„์— ํ™˜๊ฒฝ ์„ค์ •์„ ๋„ฃ์—ˆ์„ ๋•Œ๋งŒ ํ•ด๋„ properties๋ฅผ ์‚ฌ์šฉํ–ˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋Ÿฐ๋ฐ, Configuration Server๋ฅผ ์‚ฌ์šฉํ•  ๋•Œ๋Š” YML ํŒŒ์ผ ํฌ๋งท์„ ์‚ฌ์šฉํ•  ์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค. 

๋‘ ๋ฐฉ์‹์˜ ์ฐจ์ด๋Š” ์„ค์ •์„ ์–ด๋–ป๊ฒŒ ๊ตฌ์„ฑํ•˜๋Š๋ƒ์— ๋”ฐ๋ผ ๋‚˜๋ˆ„์–ด์ง‘๋‹ˆ๋‹ค. ์œ„์—์„œ Properties ํŒŒ์ผ ํฌ๋งท์„ ์‚ฌ์šฉํ–ˆ์„ ๋•Œ๋Š” ๊ฐœ๋ฐœ ํ™˜๊ฒฝ๊ณผ ๋ฐฐํฌ ํ™˜๊ฒฝ์„ ์„œ๋กœ ๋‹ค๋ฅธ ํ™˜๊ฒฝ ์„ค์ • ํŒŒ์ผ๋กœ ๋‚˜๋ˆ„์–ด ๊ตฌ์„ฑ๋งŒ ๊ฐ€๋Šฅํ•ฉ๋‹ˆ๋‹ค. 

๊ทธ๋Ÿฌ๋‚˜ YML์˜ ๊ฒฝ์šฐ, ํ•œ ๊ฐœ์˜ ์„œ๋น„์Šค์— ๋ชจ๋“  ํ™˜๊ฒฝ์˜ ํ™˜๊ฒฝ ์„ค์ •์„ ํ•œ ํŒŒ์ผ์— ๋„ฃ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. 

spring:
    profiles: dev
    message: Loaded MemberService for Development Mode..
    
---

spring:
    profiles: prod
    message: Loaded MemberService for Production Mode..

server-configs/member-service.yml

๊ฐœ๋ฐœ์ž๋งˆ๋‹ค ์ฐจ์ด๊ฐ€ ์žˆ์„ ์ˆ˜ ์žˆ๊ฒ ์ง€๋งŒ ์„ค์ • ํŒŒ์ผ์ด ์ปค์งˆ ๊ฒฝ์šฐ, ํ›„์ž์˜ ๋ฐฉ๋ฒ•์€ ๊ฑฐ์˜ ์‚ฌ์šฉ๋˜์ง€ ์•Š๊ณ , ์ „์ž์˜ ๋ฐฉ์‹์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ๋˜ ํ›„์ž์˜ ๊ฒฝ์šฐ, '---' ๊ตฌ๋ถ„์ž๋ฅผ ํ†ตํ•ด์„œ Spring Cloud Configuration Server๊ฐ€ ํŒŒ์‹ฑํ•˜์—ฌ ์ฝ๊ธฐ ๋•Œ๋ฌธ์— ๊ตฌ๋ถ„์ž๋ฅผ ๋ฐ˜๋“œ์‹œ ๋ถ™์—ฌ์ค˜์•ผ ํ•œ๋‹ค๋Š” ์ .

์œ„์™€ ๊ฐ™์€ ๋ฐฉ์‹์œผ๋กœ Note ์„œ๋น„์Šค๋„ ๋˜‘๊ฐ™์ด ๋งŒ๋“ค์–ด์ฃผ๋ฉด ๋์ž…๋‹ˆ๋‹ค.

 

Test

์ž ์ด์ œ ํ™˜๊ฒฝ ์„ค์ • ์„œ๋ฒ„๊ฐ€ ๋งŒ๋“ค์–ด์กŒ์œผ๋‹ˆ ์ด์ œ ์ด๋ฅผ ์ž˜ ๋ถˆ๋Ÿฌ์˜ค๋Š”์ง€ ํ…Œ์ŠคํŠธํ•ด๋ณด๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค. ๊ธฐ๋ณธ์ ์œผ๋กœ Configuration Server๋Š” REST API์˜ GET ๋ฉ”์†Œ๋“œ๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ JSON ํ˜•ํƒœ๋กœ ํ™˜๊ฒฝ ์„ค์ •์„ ๊ฐ€์ ธ์˜ค๊ฒŒ ๋ฉ๋‹ˆ๋‹ค.

๋”ฐ๋ผ์„œ ์•„๋ž˜์˜ ์ปค๋งจ๋“œ๋ฅผ ์ด์šฉํ•˜์—ฌ ๋ฉ”์†Œ๋“œ๊ฐ€ ์ž˜ ๋™์ž‘ํ•˜๋Š”์ง€ ํ™•์ธํ•ด๋ณด๋ฉด ๋ฉ๋‹ˆ๋‹ค.

 

$ curl http://localhost:9000/member-service/dev | json_pp

OS X / Linux์—์„œ curl ๋ช…๋ น์–ด๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ํ…Œ์ŠคํŠธํ•˜๊ฒŒ ๋˜๋ฉด ์•„๋ž˜์˜ ๊ฒฐ๊ณผ๊ฐ€ ๋‚˜ํƒ€๋‚ฉ๋‹ˆ๋‹ค.

{
   "profiles" : [
      "local"
   ],
   "version" : null,
   "name" : "member-service",
   "propertySources" : [
      {
         "source" : {
            "spring.message" : "Loaded MemberService for Development Mode..",
            "spring.profiles" : "dev"
         },
         "name" : "file:///home/neonkid/server-configs/member-service-dev.properties"
      }
   ],
   "label" : null,
   "state" : null
}

๊ฒฐ๊ณผ๊ฐ’์€ JSON ํ˜•ํƒœ๋กœ ์ถœ๋ ฅ๋˜๋ฉฐ propertySources ํŒŒ๋ผ๋ฏธํ„ฐ ๊ฐ’์ด ์œ„์™€ ๊ฐ™์ด ๋‚˜์˜ค๋ฉด ์ •์ƒ์ ์œผ๋กœ ๊ตฌ์„ฑ ์„œ๋ฒ„๊ฐ€ ๋งŒ๋“ค์–ด์ง„ ๊ฒƒ์ž…๋‹ˆ๋‹ค. ๋‹ค๋ฅธ API ๋˜ํ•œ ์œ„์™€ ๊ฐ™์€ ํ˜•ํƒœ๋กœ ํ…Œ์ŠคํŠธ ํ•ด ๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

 

๋งˆ์น˜๋ฉฐ...

๋กœ์ปฌ ํ™˜๊ฒฝ์—์„œ Spring Cloud์˜ ํ™˜๊ฒฝ ์„ค์ • ์„œ๋ฒ„๋ฅผ ๊ตฌ์„ฑํ•˜๋Š” ๋ฐฉ๋ฒ•์— ๋Œ€ํ•ด ์•Œ์•„๋ดค์Šต๋‹ˆ๋‹ค. ์ด ์™ธ์—๋„ ํ™˜๊ฒฝ ์„ค์ • ์„œ๋ฒ„๋ฅผ ๊ตฌ์„ฑํ•˜๋Š” ๋‚ด์šฉ์ด ๋” ๋งŽ์ด ์žˆ์ง€๋งŒ ์ด๋ฒˆ ๊ธ€์—์„œ๋Š” ๋กœ์ปฌ ํ™˜๊ฒฝ์— ์„ค์ • ํŒŒ์ผ์„ ์ €์žฅํ•˜๊ณ , ๋ถˆ๋Ÿฌ์˜ค๋Š” ๋ฐฉ์‹์œผ๋กœ ๋งˆ๋ฌด๋ฆฌ๋ฅผ ์ง“๊ฒŒ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

๋‹ค์Œ ํŒŒํŠธ์—์„œ๋Š” Configuration Server ๊ตฌ์„ฑ 2๋ฒˆ์งธ ์ฃผ์ œ๋กœ ์ ์–ด๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

 

 

๋ฐ˜์‘ํ˜•
TAGS.

Tistory Comments