๐ Java & Kotlin & Spring/- Spring37 [Spring] ApplicationEventPublisher ๋ฅผ ์ด์ฉํด์ Event ๋ฅผ ๋ฐํํ๋ฉด ์ด๋ค ์ผ์ด ์ผ์ด๋ ๊น ํด๋น ๊ธ์ ์ ์ฒด ์์ค์ฝ๋๋ github ์์ ํ์ธํ ์ ์์ต๋๋ค. README ๋ฅผ ์ฐธ์กฐํ์ธ์ ๋ชฉ์ฐจ ๋๊ธฐ There is No Magic in spring ๋๊ธฐ ์ต๊ทผ์ DDD ๋ฅผ ํ์ตํ๋ฉด์ ๋๋ฉ์ธ ์ด๋ฒคํธ๋ผ๋ ๊ฒ์ ์๊ฒ ๋์๋ค. ๊ทธ๋ฌ๋ฉด์ Spring ์์ ํ VM ์์์ ์ด๋ฒคํธ๋ฅผ ๋ฐํํ๊ณ ํด๋น ์ด๋ฒคํธ๋ฅผ handling ํ๋ ์ฝ๋๋ฅผ ์ ํ๊ณ , ๊ทธ์ ๊ด๋ จํด์ ์ฌ๋ฌ ์ค์ต์ ํด๋ณด๋ ์ค Spring ์์ ๋ฌด์ธ๊ฐ Magic ์ด ์ผ์ด๋๊ณ ์๋๊ฒ ๊ฐ์ ๋๋์ ๋ฐ์๋ค. ๊ธด ๋ง ํ์ ์์ด ์๋์ ์ฝ๋๋ฅผ ํ์ธํด๋ณด์. @Entity(name = "orders") public class Order { public static Order create() { return new Order(); } @Id private Long id; .. 2022. 8. 15. [Spring Boot] CORS ๋ฅผ ํด๊ฒฐํ๋ 3๊ฐ์ง ๋ฐฉ๋ฒ (Filter, @CrossOrigin, WebMvcConfigurer) Server Side Template ๋ฐฉ์์ด ์๋ Front์ Back ์ผ๋ก ๋๋ ์ ์ธํ๋ผ๋ฅผ ๊ตฌ์ฑํด๋ณธ ๊ฒฝํ์ด ์๋ ์ฌ๋๋ค์๊ฒ๋ Cors๊ฐ ๋งค์ฐ ์น์ํ ์ ์๋ค. ํ์ฌ ๊ฐ๋ฐ ํ๋ฆ์์ ์น ํ๋ก์ ํธ๋ฅผ ์งํํ๋ค๊ฐ Cors ๋ฅผ ๋ง๋ ํ๋ฅ ์ ๊ฐํ 100% ๋ผ๊ณ ํด๋ ๊ณผ์ธ์ด ์๋๋ค. ์ค๋์ CORS ๊ฐ ๋ฌด์์ธ์ง ์์๋ณด๋ฉฐ ๋, Spring Boot Application ์์๋ ์ด๋ป๊ฒ ํด๋น ์ ์ฑ ์ ํด๊ฒฐํ ์ ์๋์ง ์์๋ณด์. CORS ํด๊ฒฐํ๊ธฐ ์ฐ์ ๊ฐ์ฅ ๋จผ์ ๋ง ํ๊ณ ์ถ์ ๊ฒ์ CORS ๋ ์๋ฌ๋ ์ค๋ฅ๊ฐ ์๋๋ค. Cross-Origin Resource Sharing Policy ์ด๋ค. ์ฒ์ ๋ด๊ฐ Front ์ Back ์ ๋๋ ์ ๊ฐ๋ฐ์ ํ ๋์๋ ๋จ์ํ Front ์์ fetch ์์ฒญ์ผ๋ก Back ์ ๋ฐ๋ผ๋ณด๊ณ ๋ ๋ฆฌ๋ฉด ๋ .. 2021. 8. 14. [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 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 ยทยทยท 10 ๋ค์