viiviii / friendly-pancake

0 stars 0 forks source link

๐Ÿ”ง config: ํ…Œ์ŠคํŠธ์šฉ application.yml๋ฅผ ์ถ”๊ฐ€ํ•œ๋‹ค #130

Closed viiviii closed 4 months ago

viiviii commented 4 months ago

์ž‘์—…

์ด์œ 

์™œ

๊ตฌ์„ฑ ํŒŒ์ผ ์ ์šฉ ์ˆœ์„œ https://docs.spring.io/spring-boot/docs/3.2.5/reference/html/features.html#features.external-config

image

๊ฐœ์„  ๋ฐฉ์•ˆ

A. active ํ”„๋กœํ•„์„ ์ง€์ •ํ•˜๋Š” ๋ฐฉ๋ฒ•

์˜ˆ๋ฅผ ๋“ค์–ด, ํ…Œ์ŠคํŠธ์— ํ™œ์„ฑ ํ”„๋กœํ•„์„ test๋กœ ์ง€์ •ํ•˜๊ณ , ์™ธ๋ถ€ ๊ตฌ์„ฑ ํŒŒ์ผ์—๋Š” ํ™œ์„ฑ ํ”„๋กœํ•„์ด default์ผ ๋•Œ๋งŒ ํ•ด๋‹น ์„ค์ •์„ ํ™œ์„ฑํ™”ํ•˜๊ฒŒ ๊ตฌ์„ฑ

๋ฐ˜๋Œ€๋กœ ๋ฉ”์ธ์— ํ™œ์„ฑ ํ”„๋กœํ•„์„ ์ง€์ •ํ•˜๊ณ , ์™ธ๋ถ€ ๊ตฌ์„ฑ ํŒŒ์ผ์„ ํ•ด๋‹น ํ”„๋กœํ•„๋กœ ์ž‘์„ฑํ•˜๊ฒŒ ๊ตฌ์„ฑํ•  ์ˆ˜๋„ ์žˆ์Œ

์ด ์ผ€์ด์Šค์˜ ์žฅ์ ์€ ํ•ด๋‹น ํ”„๋กœํ•„์˜ ํŒŒ์ผ์ด ์—†์–ด๋„ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ•˜์ง€ ์•Š์œผ๋ฏ€๋กœ, ๋ฐฐํฌ์ชฝ ์ฝ”๋“œ๋ฅผ ๋ฐ”๊พธ์ง€ ์•Š์•„๋„ ๋จ

B. include ํ•˜๋Š” ๋ฐฉ๋ฒ•

์ด ๋ฐฉ๋ฒ•์€ include: secret์œผ๋กœ ์„ค์ •ํ•œ ๊ฒฝ์šฐ application-secret.yml์ด ๊ผญ ์กด์žฌํ•ด์•ผ ํ•จ

๋‹จ์ ์€ ํ•ด๋‹น ํŒŒ์ผ์ด ์กด์žฌํ•˜์ง€ ์•Š์œผ๋ฉด ์—๋Ÿฌ๊ฐ€ ๋‚œ๋‹ค๋Š” ๊ฒƒ์ด์ง€๋งŒ ์ด๊ฒŒ ๋˜ ์žฅ์ ์ผ ์ˆ˜๋„ ์žˆ๋‹ค๊ณ  ์ƒ๊ฐ. ๊ทธ๋ฆฌ๊ณ  ๋นจ๋ฆฌ ์—๋Ÿฌ๊ฐ€ ๋‚˜๊ฒŒ ๋งŒ๋“ค๊ณ  config ํด๋”์˜ ๋‚ด์šฉ๋“ค์„ resource/๋กœ ์˜ฎ๊ฒจ์„œ ๊ด€๋ฆฌํ•˜๋Š” ๊ฒƒ๋„ ์ข‹๋‹ค๊ณ  ์ƒ๊ฐํ•จ.

๋Œ€์‹  ํ˜„์žฌ ๋ฐฐํฌ์ชฝ ์ฝ”๋“œ๋ฅผ ๋ฐ”๊ฟ”์ค˜์•ผ ํ•จ

๊ฒฐ์ •

์ผ๋‹จ (A) ๋ฐฉ์‹์œผ๋กœ ๋ณ€๊ฒฝํ•จ. ์ด์œ ๋Š” ํ˜„์žฌ ์ƒํƒœ์—์„œ ๊ฐ€์žฅ ์‰ฝ๊ณ  ๋ณ€๊ฒฝ์ด ์ ๊ฒŒ ์ ์šฉํ•  ์ˆ˜ ์žˆ๊ธฐ ๋•Œ๋ฌธ