๐ Java & Kotlin & Spring/- spring framework +43 Spring Cloud Config์ name, profiles ๊ทธ๋ฆฌ๊ณ Github ๋ฅผ ์ฐ๋ํด์ ์ค์ ํ์ผ ๊ด๋ฆฌํ๊ธฐ ํด๋น ๊ธ์ Spring Cloud Config ๋ก Application์ ์ค์ ์ ๋ณด๋ฅผ ์ค์์์ ๊ด๋ฆฌํ๊ธฐ์ ์์กดํ๋ ๊ธ์ ๋๋ค. ์ค์ต ํ๊ฒฝ์ ๋ฐ๋ผํ์๋ ค๋ฉด ์ด์ ๊ธ์ ๋์จ ์ค์ต์ ๋ฐ๋ผํ์๊ธธ ๊ถ๊ณ ๋๋ฆฝ๋๋ค. ๋ชฉ์ฐจ ์ธ๋ถ ์ค์ ๊ด๋ฆฌ ๋ฐฉ๋ฒ ๊ธฐ๋ณธ ๋ง์ฝ ์ค์ ํ์ผ์ด ์ฌ๋ฌ ๊ฐ๋ผ๋ฉด? ๊ฒ๋ค๊ฐ ๊ฐ๊ฐ ๋จ๊ณ๋ณ๋ก ๊ตฌ์ฑํด์ผ ํ๋ ํ์ผ์ด ๋ค๋ฅด๋ค๋ฉด? ์ด๋ด ๋ profiles ๊ฐ ๋ฑ์ฅ profiles Spring boot ์์ profiles ์ ๋ฐ๋ฅธ ์ค์ ๊ฐ๊ธฐ ๋ค๋ฅธ ์ค์ ์ ๋ณด ๊ฐ์ ธ์ค๊ธฐ naming ์ ๋ต config ์๋ฒ url ์ ๋ฐ๋ฅธ ์ค์ profile Config ์๋ฒ์ Git Remote Repository ์ฐ๋ํ์ฌ ์ค์ ํ์ผ ๊ด๋ฆฌํ๊ธฐ Git Repository ์์ฑ Git ์ ์ฅ์ ์์ฑ Config ์๋ฒ์์ git url ์ฐ๊ฒฐ Use.. 2021. 4. 27. [Spring Cloud Config] Application์ ์ค์ ์ ๋ณด (application.yml) ๋ฅผ ์ค์์์ ๊ด๋ฆฌํ๊ธฐ (by native repository) ํด๋น ๊ธ์ Spring Cloud Netflix Eureka ์ Spring Cloud Gateway ์ Built-in Route๋ก Predicates์ Filter ์กฐ์ํ๊ธฐ)์ ์์กดํ๋ ๊ธ์ ๋๋ค. ์ค์ต ํ๊ฒฝ์ ๋ฐ๋ผํ์๋ ค๋ฉด Eureka์ Gateway ๊ธ์ ๋์จ ์ค์ต์ ๋ฐ๋ผํ์๊ธธ ๊ถ๊ณ ๋๋ฆฝ๋๋ค. ๋ชฉ์ฐจ Gartner ์์ ์ ์๋ MSA ํ์ค ๊ตฌ์ฑ ์์์ธ Config Store Server ์์ฃผ ๋ณ๊ฒฝ๋๋ ์ค์ ์ ๋ณด๋ ์ค์ ์ ๋ณด๋ง ๋ด๊ณ ์๋ ์๋ฒ์์ ๊ด๋ฆฌํ๊ณ ์ด๋ฅผ ํ์๋ก ํ๋ ์๋ฒ์๊ฒ ๊ฐ๊ฐ ๋ฟ๋ ค์ฃผ๋ ๋ฐฉ์ ์ฐ๋ฆฌ๊ฐ ๊ตฌ์ฑํ ์๋น์ค ๊ตฌ์กฐ ๊ฐ๊ฐ์ application.yml ์๋น์ค ๊ตฌ์กฐ์ ๋ฌธ์ ์ Spring Cloud Config ๋? ์ค์ต Spring Cloud Config ํ๋ก์ ํธ ์์ฑํ๊ธฐ @EnableConfig.. 2021. 4. 27. [Spring Boot] Profile.active ์ ์ด์ฉํ์ฌ ๋ค๋ฅธ ์ค์ ์ ๋ณด(application.properties) ๋ถ๋ฌ์ค๊ธฐ application.properties ํ์ผ ์ฐ๋ฆฌ๋ application.yml ์ด๋ application.properties ํ์ผ์ ์ด์ฉํด์ ์ค์ ์ ๋ณด๋ฅผ ์ถ๊ฐํ๊ณค ํ๋ค. server: port: 56237 spring: application: name: user-service datasource: url: 232.221.123.33 driver: h2.Driver username: ffowidl123 password: "{cipher}ff01fjosdifj02034j5;jasdj5rq239y48f" ์ฐ๋ฆฌ๊ฐ ๊ฐ๋ฐํ๋ application์ ๋ค์ํ ํ๊ฒฝ์์ ๊ฐ๋ฐ๋์ด์ง๋ค. ์ด๋ฅผํ ๋ฉด ๊ธฐ๋ฅ ๊ฐ๋ฐ์ ์ํ dev ํ๊ฒฝ, ๊ธฐ๋ฅ ํ ์คํธ๋ฅผ ์ํ test ํ๊ฒฝ, ๊ธฐ๋ฅ ๋ฐฐํฌ๋ฅผ ์ํ production ํ๊ฒฝ ๋ฑ๋ฑ ๊ฐ๊ฐ์ ๋ง.. 2021. 4. 26. [Spring Cloud Gateway] Custom Filter ๋ก ๊ฐ๋จํ Authentiction ํํฐ ๋ง๋ค๊ณ ์ธ์ฆ ์ฒ๋ฆฌํ๊ธฐ ํด๋น ๊ธ์ Spring Cloud Gateway ์ Built-in Route๋ก Predicates์ Filter ์กฐ์ํ๊ธฐ) ์ ์์กดํ๋ ๊ธ์ ๋๋ค. ์ค์ต ํ๊ฒฝ์ ๋ฐ๋ผํ์๋ ค๋ฉด ์ด์ ๊ธ์ ํ์ธํ์๊ธธ ๋ฐ๋๋๋ค. ํ์ฌ ๊ธ์์๋ ๋ชจ๋ ์ธ์ฆ ๊ณผ์ (jwt ํ ํฐ์ ๋ฐ๊ธํ๊ณ payload ์ ๊ฐ์ ๋ฃ๋ ์ค์ ๊ตฌํ)์ ํ์ง ์์ต๋๋ค. ์ด๋ฒ ๊ธ์ ๋ชฉ์ ์ Gateway ์์ Custom Filter ๋ง๋ค์ด์ ํ ํฐ ๊ฒ์ฆ์ ์ํํ๋ ์ ์ฒด์ ์ธ ํฐ ๊ทธ๋ฆผ๋ง ๋ณด์ฌ์ฃผ๋ ค ํ๊ธฐ ๋๋ฌธ์ ์ค์ ์ธ์ฆ์ ๊ตฌํํ๋ ค ํ๋ค๋ฉด ์ฐธ๊ณ ๋ง ํ์๊ธธ ๋ฐ๋๋๋ค. ๋ชฉ์ฐจ Custom Filter AbstractGatewayFilterFactory ์์๊ณผ apply ์ฌ์ ์ ๊ฒ์ฆํ๊ธฐ Custom Filter ์ง๋ ์๊ฐ๊น์ง ์ฐ๋ฆฌ๋ Spring Cloud Gateway๊ฐ ๊ธฐ.. 2021. 4. 25. Spring Cloud Gateway ์์ Built-in Route๋ก Predicates์ Filter ์กฐ์ํ๊ธฐ ํด๋น ๊ธ์ SGC๋ฅผ ์ด์ฉํด API Gateway๋ฅผ ๊ตฌ์ฑํ๊ณ Eureka Server ๋ฅผ ์ด์ฉํด Load Balancing ํ๊ธฐ) ์ ์์กดํ๋ ๊ธ์ ๋๋ค. ์ค์ต ํ๊ฒฝ์ ๋ฐ๋ผํ์๋ ค๋ฉด ์ด์ ๊ธ์ ํ์ธํ์๊ธธ ๋ฐ๋๋๋ค. ๋ชฉ์ฐจ Spring Cloud Gateway Routes, Predicates, Filters Route Predicates Built-in Factories ์ฌ์ฉํ๊ธฐ After Cookie Method Path Route Filters AddRequestHeader, AddResponseHeader AddRequestParameter RewritePath Spring Cloud Gateway ์์๋ Predicates์ Filter๋ฅผ ์กฐ์ํ๋ ๋ฐฉ๋ฒ์ application.yml ์ ์ด์ฉํ short.. 2021. 4. 24. [Spring Boot] ํฐ๋ฏธ๋์์ ๋น๋ ํด (Maven, Gradle)๋ก Spring Boot ์คํ์ํค๊ธฐ ์ค๋์ ํฐ๋ฏธ๋์์ Springboot Application ์ ์คํ์ํค๋ ๋ฐฉ๋ฒ์ ๋ํด์ ์์๋ณด๋ ค ํ๋ค. ํ์ฌ Microservice Application ์ ๊ฐ๋ฐํ๊ธฐ ์ํด์ ์ฃผ๋ก Eureka์ Gateway ๋ฅผ ํจ๊ป ๋์์ํค๋ ์ผ์ด ๋ง์์ก๋ค. Service Discovery ์ญํ ์ ์ํํ๋ Eureka ์๋ฒ๋ ๋จ์ง ์๋น์ค์ Registry์ Discovery ์ํฉ์์ ์ผ๋๊ณ ๋ง ์์ด์ผ ํ๋ ์ํฉ์ด ์์ฃผ ๋ฐ์ํ๋๋ฐ, ๋ก์ปฌ ๊ฐ๋ฐ ํ๊ฒฝ์์ ๊ธฐ๋ฅ ๊ฐ๋ฐ์ ์ํด์๋ Eureka ์๋ฒ์ Gateway ๋ฅผ Intellij ์์ ์ผ๋๋ ๊ฒ์ด ๋๋ค์์ด๋ค. ํ์ง๋ง Intellij ๋ ๋ค์ํ ๊ธฐ๋ฅ์ ๊ฐ๊ณ ์๋ ์กฐ๊ธ ๋ฌด๊ฑฐ์ด IDE ์ด๊ธฐ ๋๋ฌธ์ ํด๋น PC์ ๋ฆฌ์์ค๋ฅผ ๋ง์ด ๋จน์ด ๋ถํธํ ์ํฉ์ด ์ด๋ง์ ๋ง์ด ์๋๋ค. ๊ทธ๋ด ๋ ๋ง์ ํด๊ฒฐ ๋ฐฉ.. 2021. 4. 24. ์ด์ 1 2 3 4 5 6 ยทยทยท 8 ๋ค์