Loading...
2023. 10. 9. 20:52

[Spring boot] Node Gradle์„ ์ด์šฉํ•˜์—ฌ Spring ํ”„๋กœ์ ํŠธ์™€ Node ํ”„๋กœ์ ํŠธ ๋ถ™์ด๊ธฐ

Spring boot๋ฅผ ์ด์šฉํ•˜์—ฌ ์›น ํŽ˜์ด์ง€๋ฅผ ๊ฐœ๋ฐœํ•  ๋•Œ๋Š” REST API ์„œ๋ฒ„๋กœ ๋ฐฑ์—”๋“œ๋ฅผ ๊ตฌํ˜„ํ•˜๊ณ , ํŽ˜์ด์ง€๋Š” ์„œ๋ฒ„ ์‚ฌ์ด๋“œ ๋ Œ๋”๋ง(SSR)์„ ์ด์šฉํ•˜์—ฌ ๊ตฌํ˜„ํ•ฉ๋‹ˆ๋‹ค. ์ด ๋•Œ ์‚ฌ์šฉํ•˜๋Š” ๊ธฐ์ˆ ์€ ์•„๋ž˜์˜ 2๊ฐ€์ง€ ๊ธฐ์ˆ ์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. JSP (Java Server Page) Thymeleaf JSP์™€ Thymeleaf๋Š” Spring์„ ์ด์šฉํ•˜์—ฌ ํ™”๋ฉด์„ ๊ตฌํ˜„ํ•  ๋•Œ ์‚ฌ์šฉํ•˜๋Š” ๋ทฐ ํ…œํ”Œ๋ฆฟ ์—”์ง„์œผ๋กœ ๊ณผ๊ฑฐ์—๋Š” JSP๋ฅผ ์ด์šฉํ•˜์—ฌ ํ™”๋ฉด์„ ๊ตฌํ˜„ํ–ˆ์ง€๋งŒ ์ตœ๊ทผ์—๋Š” Thymeleaf๋ฅผ ๋งŽ์ด ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ์ด๋ ‡๊ฒŒ HTML ์ฝ”๋“œ๋ฅผ ์ง์ ‘ ํ…œํ”Œ๋ฆฟ์œผ๋กœ ๋‹ค๋ค„ Controller์˜ ๋ฐ์ดํ„ฐ๋ฅผ ์ด์šฉํ•ด ๋™์ ์œผ๋กœ ํ™”๋ฉด์„ ๋งŒ๋“ค์–ด์ฃผ๋Š” ๊ฒƒ์„ ์„œ๋ฒ„ ์‚ฌ์ด๋“ค ๋ Œ๋”๋ง์ด๋ผ ํ•ฉ๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ ์ตœ๊ทผ์—๋Š” ํด๋ผ์ด์–ธํŠธ ์‚ฌ์ด๋“œ ๋ Œ๋”๋ง(CSR) ๊ธฐ๋ฒ•์„ ์ด์šฉํ•œ React.js, Vue.js๋ฅผ ์ด..

2023. 1. 15. 16:27

[Netty] Netty๋กœ ๋ฐฐ์›Œ๋ณด๋Š” Non-blocking I/O ๊ธฐ์ดˆ

์˜ค๋Š˜์€ Java ๋„คํŠธ์›Œํฌ ํ”„๋กœ๊ทธ๋ž˜๋ฐ์˜ ๊ฝƒ์ธ Netty์— ๋Œ€ํ•ด ์•Œ์•„๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. What is Netty ? Netty๋ฅผ ๋“ค์–ด๋ณด์‹  ๋ถ„๋“ค์ด๋ผ๋ฉด ์•„๋งˆ ํ•œ ๋ฒˆ ์ฏค c10k ๋ฌธ์ œ๋ผ๋Š” ๊ฒƒ์„ ๊ฒฝํ—˜ํ•ด๋ณด์…จ๊ฑฐ๋‚˜ ๊ด€์‹ฌ์„ ๊ฐ€์กŒ์„๋งŒํ•œ ๋ถ„์ด์‹ค ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค. Netty๋Š” JVM์—์„œ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” Java NIO ๊ธฐ๋ฐ˜์˜ Non-blocking ํ”„๋ ˆ์ž„์›Œํฌ์ž…๋‹ˆ๋‹ค. ์–ด๋Š ํŠน์ • ํ”„๋กœํ† ์ฝœ(HTTP ๋“ฑ)์˜ ์„œ๋ฒ„๋ฅผ ๊ตฌํ˜„ํ•˜๋Š” ๊ฒƒ์ด ์•„๋‹Œ TCP, UDP์˜ ๋„คํŠธ์›Œํฌ ํ†ต์‹ ์„ Non-blocking I/O๋กœ ์ฒ˜๋ฆฌํ•˜์—ฌ ์„œ๋ฒ„์™€ ํด๋ผ์ด์–ธํŠธ๋ฅผ ๊ฐœ๋ฐœํ•˜๋Š” ํ”„๋ ˆ์ž„์›Œํฌ์ž…๋‹ˆ๋‹ค. Non-blocking์ด ๋ฌด์—‡์ธ๊ฐ€์š”? ๊ฐ„๋‹จํ•˜๊ฒŒ ์„ค๋ช…ํ•˜์ž๋ฉด, ์–ด๋– ํ•œ ์ž‘์—…์„ ๋ง‰ํž˜์—†์ด ์ด์–ด๋‚˜๊ฐˆ ์ˆ˜ ์žˆ๋„๋ก ํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค. ๊ฐ„๋‹จํ•œ ์˜ˆ์‹œ๋ฅผ ๋“ค์–ด๋ณด์ž๋ฉด ์šฐ๋ฆฌ๊ฐ€ ๋ง›์žˆ๋Š” ๋ง›์ง‘์—๊ฐ€์„œ ์Œ์‹์„ ๋จน์œผ๋Ÿฌ ๊ฐ”์Šต๋‹ˆ๋‹ค. ..

2022. 11. 6. 21:49

[Spring] ๋น„๋™๊ธฐ ์ž‘์—…๊ณผ ๋ชจ๋‹ˆํ„ฐ๋ง์„ ์œ„ํ•œ TaskExecutor, TaskScheduler ๊ธฐ๋ณธ

Spring Framework๋Š” TaskExecutor ์ธํ„ฐํŽ˜์ด์Šค์™€ TaskScheduler ์ธํ„ฐํŽ˜์ด์Šค๋กœ Task(์ž‘์—…)์˜ ๋น„๋™๊ธฐ ์‹คํ–‰๊ณผ ์Šค์ผ€์ค„๋ง์— ๋Œ€ํ•œ ์ถ”์ƒํ™” ์ธํ„ฐํŽ˜์ด์Šค๋ฅผ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. ์ด๋Ÿฐ ๊ฒƒ์ด ํ•„์š”ํ•œ ์ด์œ ๋Š” ๋ฌด์—‡์ผ๊นŒ์š”? ๊ธฐ๋ณธ์ ์œผ๋กœ Spring์€ Multi-Thread ๋ฐฉ์‹์„ ์‚ฌ์šฉํ•˜๋ฉฐ Singleton Pattern์„ ์ด์šฉํ•ด ๋ชจ๋“  Bean๋“ค์„ ๊ณต์œ ํ•˜์—ฌ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ ์ด๋Š” ๊ธฐ๋ณธ์ ์œผ๋กœ API๋ฅผ ํ˜ธ์ถœํ•˜๋Š” ๊ณผ์ •์„ Blockingํ•˜์ง€ ์•Š๊ณ  ๋‹ค์ค‘ ์‚ฌ์šฉ์ž๊ฐ€ ์š”์ฒญ์„ ๋ฐ›์„ ์ˆ˜ ์žˆ๋„๋ก ์ฒ˜๋ฆฌํ•œ๋‹ค๋Š” ๋œป์ž…๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ ์šฐ๋ฆฌ๊ฐ€ API ํ˜ธ์ถœ ์ดํ›„ Bean ๋‚ด ์–ด๋–ค ํŠน์ • ์ž‘์—…์— ๋Œ€ํ•œ ๋น„๋™๊ธฐ ์‹คํ–‰์€ ๋ณด์žฅ๋˜์ง€ ์•Š์Šต๋‹ˆ๋‹ค. TaskExecutor TaskExecutor๋Š” Spring 2.0์—์„œ ๋“ฑ์žฅํ•œ ๋น„๋™๊ธฐ ์‹คํ–‰ ์ถ”์ƒํ™” ์ธํ„ฐํŽ˜์ด์Šค๋กœ..

2022. 10. 30. 16:57

[Rust] ๊ฐœ๋…๋ถ€ํ„ฐ ๊ฐœ๋ฐœ ํ™˜๊ฒฝ ๊ตฌ์ถ•๊นŒ์ง€ ์ฐจ๊ทผ์ฐจ๊ทผ ์‹œ์ž‘ํ•ด๋ณด๊ธฐ

์š”์ฆ˜ ๋ชจ๋˜ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด๊ฐ€ ๋งŽ์ด ๋‚˜์˜ค๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ๊ตฌ๊ธ€์˜ Golang, ๋ชจ์งˆ๋ผ์˜ Rust ๋ฟ๋งŒ ์•„๋‹ˆ๋ผ ํ•จ์ˆ˜ํ˜• ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด์ธ Clojure, Rescript ๋“ฑ ๋‹ค์–‘ํ•œ ์–ธ์–ด๊ฐ€ ๋งŽ์ด ๋‚˜์˜ค๊ณ  ์žˆ๋Š”๋ฐ์š”. ํŠนํžˆ ์ตœ๊ทผ์—๋Š” ๊ตฌ๊ธ€์—์„œ C++ ๋Œ€ํ•ญ ์–ธ์–ด๋กœ Carbon์ด๋ผ๋Š” ์–ธ์–ด๊นŒ์ง€๋„ ๋‚˜์™”์Šต๋‹ˆ๋‹ค. ์ด๋ฒˆ์— ๋‹ค๋ฃฐ ์ฃผ์ œ๋Š” ๋ฐ”๋กœ ๋ชจ์งˆ๋ผ์˜ Rust์ธ๋ฐ์š”. ์ตœ๊ทผ ๋ฆฌ๋ˆ…์Šค ์ปค๋„ ๊ฐœ๋ฐœ์—๋„ Rust ์–ธ์–ด๊ฐ€ ๊ณต์‹ ์ฑ„ํƒ๋˜์–ด ํ™”๋‘๊ฐ€ ๋˜๊ณ  ์žˆ๋Š” Rust์— ๋Œ€ํ•ด ์•Œ์•„๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค. What is Rust? ์ œ๊ฐ€ ์ฒ˜์Œ Rust ์–ธ์–ด๋ฅผ ๋“ค์—ˆ์„ ๋•Œ๋Š” 3๋…„ ์ „, YouTube์˜ ์ผ€๋นˆ๋‹˜ ๋ฐฉ์†ก์—์„œ์˜€์Šต๋‹ˆ๋‹ค. ๊ทธ ๋•Œ๋ถ€ํ„ฐ ์ญˆ์šฑ ์•„๋ฌด๊ฒƒ๋„ ํ•ด์˜ค์ง€ ์•Š์•˜์—ˆ์Šต๋‹ˆ๋‹ค๋งŒ Golang๊ณผ Rust ๋‘˜ ์ค‘ ์—„์ฒญ ์ €์šธ์งˆ์„ ํ–ˆ์—ˆ๊ธฐ ๋•Œ๋ฌธ์ด์—ˆ์ฃ . ํ•˜์ง€๋งŒ ์ด์ œ๋Š” ์ž์‹ ์žˆ๊ฒŒ Rust ์–ธ..

2022. 10. 29. 22:07

[Spring] Spring Advisor์™€ Pointcut - ์‹ค์ „ํŽธ

์ด์ „ ๊ธ€์—์„œ DefaultPointcutAdvisor์™€ ๋‹ค์–‘ํ•œ Pointcut๋“ค์— ๋Œ€ํ•œ ๊ฐœ๋…์„ ๋‹ค๋ค„๋ดค์Šต๋‹ˆ๋‹ค. 2022.10.10 - [Programming/Spring] - [Spring] Spring Advisor์™€ Pointcut - ๊ฐœ๋…ํŽธ [Spring] Spring Advisor์™€ Pointcut - ๊ฐœ๋…ํŽธ Spring AOP ์ปดํฌ๋„ŒํŠธ๋ฅผ ์ด์šฉํ•ด Advice๋ฅผ ๋งŒ๋“ค์–ด ๋ฉ”์„œ๋“œ์˜ ์ „ํ›„์ฒ˜๋ฆฌ๋ฅผ ํ”„๋ก์‹œ ๊ฐ์ฒด๋ฅผ ํ†ตํ•ด ๊ตฌํ˜„ํ•ด๋ดค์Šต๋‹ˆ๋‹ค. 2022.05.16 - [Programming/Spring] - [Spring] Spring Advice๋กœ ์ปค์Šคํ…€ ์–ด๋“œ๋ฐ”์ด์Šค ๋งŒ๋“ค๊ธฐ [Spring] Spr.. blog.neonkid.xyz Pointcut์€ ์ธํ„ฐํŽ˜์ด์Šค ํ˜•ํƒœ๋กœ ๋˜์–ด ์žˆ์ง€๋งŒ Spring AOP์—์„œ ์ด๋ฏธ ๋งŽ์€ ๊ตฌํ˜„์ฒด๋“ค์ด..

2022. 10. 10. 19:11

[Spring] Spring Advisor์™€ Pointcut - ๊ฐœ๋…ํŽธ

Spring AOP ์ปดํฌ๋„ŒํŠธ๋ฅผ ์ด์šฉํ•ด Advice๋ฅผ ๋งŒ๋“ค์–ด ๋ฉ”์„œ๋“œ์˜ ์ „ํ›„์ฒ˜๋ฆฌ๋ฅผ ํ”„๋ก์‹œ ๊ฐ์ฒด๋ฅผ ํ†ตํ•ด ๊ตฌํ˜„ํ•ด๋ดค์Šต๋‹ˆ๋‹ค. 2022.05.16 - [Programming/Spring] - [Spring] Spring Advice๋กœ ์ปค์Šคํ…€ ์–ด๋“œ๋ฐ”์ด์Šค ๋งŒ๋“ค๊ธฐ [Spring] Spring Advice๋กœ ์ปค์Šคํ…€ ์–ด๋“œ๋ฐ”์ด์Šค ๋งŒ๋“ค๊ธฐ ์ด๋ฒˆ ํฌ์ŠคํŠธ๋ถ€ํ„ฐ๋Š” Spring AOP ์ปดํฌ๋„ŒํŠธ๋ฅผ ์ด์šฉํ•˜์—ฌ ์‹ค์ œ Advice๋ฅผ ๋งŒ๋“ค์–ด๋ณด๊ณ , ์œ„๋น™ํ•˜๋Š” ์‹œ๊ฐ„์„ ๊ฐ€์ ธ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. Advice Interface Advice์— ๋Œ€ํ•ด ๋‹ค์‹œ ๋ณต์Šตํ•ด๋ณด์ž๋ฉด Advice๋Š” ํŠน์ • ์กฐ์ธํฌ์ธํŠธ ์ฆ‰, ๋ฉ”์„œ๋“œ๊ฐ€ blog.neonkid.xyz Spring AOP์˜ ProxyFactory ํด๋ž˜์Šค๋Š” ์šฐ๋ฆฌ๊ฐ€ ์ž‘์„ฑํ•œ ๋ฉ”์„œ๋“œ์—์„œ AOP ํ”„๋ก์‹œ ์ธ์Šคํ„ด์Šค๋ฅผ ์–ป๊ณ  ๊ตฌ์„ฑํ•˜๋Š” ๊ฐ„๋‹จํ•œ ๋ฐฉ๋ฒ•์„ ..

2022. 7. 2. 15:21

[OpenCV] ์›ํ•˜๋Š” ์ด๋ฏธ์ง€ ์˜์—ญ(๊ด€์‹ฌ์˜์—ญ, ROI) ์ž๋ฅด๊ธฐ(Crop)

๋ธ”๋กœ๊ทธ ๊ธ€์„ ์“ฐ๋‹ค๋ณด๋ฉด ํŠน์ • ์˜์—ญ๋งŒ์„ ์ž˜๋ผ์„œ ์ €์žฅํ•˜๊ณ  ์‹ถ์„ ๋•Œ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. ์œˆ๋„๋ฅผ ์‚ฌ์šฉํ•˜๋‹ค๋ณด๋ฉด ์œˆ๋„์—์„œ ์ œ๊ณตํ•˜๋Š” Windows ์‚ฌ์ง„ ๋ทฐ์–ด ๋“ฑ์˜ ํ”„๋กœ๊ทธ๋žจ์„ ์ด์šฉํ•ด ์›ํ•˜๋Š” ์ด๋ฏธ์ง€์˜ ์˜์—ญ์„ ์ž๋ฅผ ์ˆ˜ ์žˆ๋Š”๋ฐ, Mac OS X๋‚˜ Ubuntu์— ์žˆ๋‹ค๋ณด๋ฉด ๊ธฐ๋ณธ ํ”„๋กœ๊ทธ๋žจ์œผ๋กœ ์ด๋Ÿฐ ๊ฒƒ๋“ค์„ ์ œ๊ณตํ•˜์ง€ ์•Š๋‹ค๋ณด๋‹ˆ ์“ธ ํ”„๋กœ๊ทธ๋žจ์„ ์ฐพ๊ฒŒ ๋˜๋Š” ๊ฒฝ์šฐ๊ฐ€ ์žฆ์•˜๋Š”๋ฐ์š”. ์ด๋ ‡๊ฒŒ ์›ํ•˜๋Š” ์ด๋ฏธ์ง€๋ฅผ ๋ถˆ๋Ÿฌ์™€์„œ ๊ฐ„๋‹จํ•˜๊ฒŒ ์›ํ•˜๋Š” ์˜์—ญ์„ ์ž๋ฅผ ์ˆ˜ ์žˆ๋Š” ํ”„๋กœ๊ทธ๋žจ์„ ํ•œ ๋ฒˆ ๋งŒ๋“ค์–ด๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค. MouseEvent OpenCV์—์„œ MouseEvent๋ฅผ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด์„œ๋Š” ์ฝœ๋ฐฑ ํ•จ์ˆ˜๋ฅผ ๊ตฌํ˜„ํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์ฝœ๋ฐฑ ํ•จ์ˆ˜์— ๋Œ€ํ•ด ์ž˜ ๋ชจ๋ฅด์‹œ๊ฒ ๋‹ค๋ฉด ์•„๋ž˜์˜ ๊ธ€์„ ์ฐธ๊ณ ํ•ด๋ณด์„ธ์š”. 2016.12.18 - [Programming/OpenCV] - OpenCV์—์„œ Mouse Even..

2022. 7. 2. 14:02

[OpenCV] C++์™€ OpenCV 4.x๋กœ ๊ฐœ๋ฐœํ•  ์ˆ˜ ์žˆ๋Š” ํ™˜๊ฒฝ ๋งŒ๋“ค๊ธฐ

๊ฐ„๋งŒ์— OpenCV ๊ธ€์„ ์ž‘์„ฑํ•˜๊ฒŒ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ์š” ๋ช‡๋…„ ๋ฐฑ์—”๋“œ ์—”์ง€๋‹ˆ์–ด๋ง ๊ณต๋ถ€๋ฅผ ํ•˜๊ฒŒ ๋˜๋ฉด์„œ ์žฅ๋‚œ๊ฐ์ฒ˜๋Ÿผ ์—ฌ๊ฒจ์˜ค๋˜ OpenCV ๊ธ€์„ ๋‹ค์‹œ ์“ฐ๊ฒŒ ๋˜์—ˆ๋Š”๋ฐ์š”. ์•ˆ ๋ณธ ์‚ฌ์ด์— ๋ฒŒ์จ OpenCV 4.6 Pre-release๋กœ OpenCV 5.x ๋ฒ„์ „๊นŒ์ง€ ์˜ฌ๋ผ์˜จ ๊ฒƒ์„ ๋ณด๊ณ  ์ •๋ง ์‹œ๊ฐ„์ด ๋นจ๋ฆฌ ํ˜๋Ÿฌ๊ฐ€๊ณ  ์žˆ๋‹ค๋Š” ๊ฒƒ์„ ์ƒˆ์‚ผ ๋Š๊ผˆ์Šต๋‹ˆ๋‹ค. ๋งŒ๋“ค ํ™˜๊ฒฝ ์˜ค๋Š˜์€ ์•„๋ž˜์˜ 3๊ฐ€์ง€ ๋„๊ตฌ๋ฅผ ์‚ฌ์šฉํ•ด์„œ OpenCV ๊ฐœ๋ฐœ ํ™˜๊ฒฝ์„ ๋งŒ๋“ค์–ด๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค. JetBrains CLion / CMake OpenCV 4.6 Ubuntu Linux 20.04 ์‚ฌ์‹ค OpenCV๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ๋Š” ํ™˜๊ฒฝ์€ C++ ์™ธ์—๋„ Python์ด ์žˆ๋Š”๋ฐ์š”. ๋”ฅ๋Ÿฌ๋‹์ด๋‚˜ ๋จธ์‹ ๋Ÿฌ๋‹์„ ์ฃผ๋กœ ํ•˜์‹œ๋Š” ๋ถ„๋“ค์€ Python์„ ์ด์šฉํ•  ๊ฒƒ์ด๊ณ , ๊ทธ ์™ธ IoT๋‚˜ ์นด๋ฉ”๋ผ ๋“ฑ ํ•˜๋“œ์›จ์–ด๋ฅผ ์ฃผ๋กœ ..

2022. 6. 26. 15:50

[Spring] OSIV๋กœ ์•Œ์•„๋ณด๋Š” Spring Transaction ํ—ค์งš๊ธฐ

Spring boot์—๋Š” spring.jpa.open-in-view๋ผ๊ณ  ํ•˜๋Š” ์˜ต์…˜์ด ์žˆ์Šต๋‹ˆ๋‹ค. ์ด ์˜ต์…˜์€ JPA์˜ OSIV ๊ธฐ๋Šฅ์„ ON/OFF ํ•  ์ˆ˜ ์žˆ๋Š” ์˜ต์…˜์ธ๋ฐ์š”. ์ด ์˜ต์…˜์ด ๋ฌด์—‡์ธ์ง€ ์•Œ์•„๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค. OSIV ๋จผ์ € ์ด ์˜ต์…˜์€ JPA์˜ OSIV ๊ธฐ๋Šฅ์˜ ์‚ฌ์šฉ ์œ ๋ฌด๋ฅผ ๋‚˜ํƒ€๋‚ด๋Š”๋ฐ, OSIV๋ž€, ์˜์†์„ฑ ์ปจํ…์ŠคํŠธ๋ฅผ View๊นŒ์ง€ ์—ด์–ด๋‘๋Š” ๊ธฐ๋Šฅ์ž…๋‹ˆ๋‹ค. ์˜์†์„ฑ ์ปจํ…์ŠคํŠธ๊ฐ€ ๋ฌด์—‡์ธ์ง€ ์ž˜ ๋ชจ๋ฅด์‹œ๊ฒ ๋‹ค๋ฉด ์•„๋ž˜ ๊ธ€์„ ์ฐธ๊ณ ํ•ด๋ณด์„ธ์š”. 2020.06.23 - [Programming/Spring] - [Spring] JPA์˜ ์˜์†์„ฑ ์ปจํ…์ŠคํŠธ์™€ ์ƒ๋ช…์ฃผ๊ธฐ [Spring] JPA์˜ ์˜์†์„ฑ ์ปจํ…์ŠคํŠธ์™€ ์ƒ๋ช…์ฃผ๊ธฐ Spring Framework๋ฅผ ์ด์šฉํ•˜์—ฌ ์›น ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์ด๋‚˜ ์„œ๋ฒ„ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ๊ฐœ๋ฐœํ•  ๋•Œ ์‚ฌ์šฉํ•˜๋Š” DB ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค..

2022. 6. 22. 21:33

[Programming] SOLID - ๊ฐ์ฒด ์ง€ํ–ฅ 5๋Œ€ ์„ค๊ณ„ ์›์น™

์ด๋ฒˆ ํฌ์ŠคํŠธ์—์„œ๋Š” ํŠน์ • ์–ธ์–ด์— ๋Œ€ํ•œ ํ•™์Šต์ด ์•„๋‹Œ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์Šคํ‚ฌ์— ๋Œ€ํ•ด ์ ์–ด๋ณด๊ณ ์ž ํ•ฉ๋‹ˆ๋‹ค. ๋…์ž ์—ฌ๋Ÿฌ๋ถ„๋“ค ์ค‘ Java, C#, Python๊ณผ ๊ฐ™์€ ๊ฐ์ฒด ์ง€ํ–ฅ ํ”„๋กœ๊ทธ๋ž˜๋ฐ ์–ธ์–ด๋ฅผ ์‚ฌ์šฉํ•˜์‹œ๊ณ  ๊ณ„์‹ ๋‹ค๋ฉด OOP(๊ฐ์ฒด ์ง€ํ–ฅ ํ”„๋กœ๊ทธ๋ž˜๋ฐ)์ด๋ผ๋Š” ๋‹จ์–ด๋ฅผ ์‰ฝ๊ฒŒ ์ ‘ํ•ด๋ณด์…จ์„ ๊ฒƒ์ž…๋‹ˆ๋‹ค. OOP (Object Oriented Programming) OOP๋Š” ์šฐ๋ฆฌ ๋ง๋กœ ๊ฐ์ฒด ์ง€ํ–ฅ ํ”„๋กœ๊ทธ๋ž˜๋ฐ์ด๋ผ๋Š” ๋œป์ž…๋‹ˆ๋‹ค. ์ด ๊ฐ์ฒด ์ง€ํ–ฅ ํ”„๋กœ๊ทธ๋ž˜๋ฐ์„ ์œ„ํ‚ค์—์„œ ๋ณด๋ฉด ์•„๋ž˜์™€ ๊ฐ™์Šต๋‹ˆ๋‹ค. ๊ฐ์ฒด ์ง€ํ–ฅ ํ”„๋กœ๊ทธ๋ž˜๋ฐ - ์œ„ํ‚ค๋ฐฑ๊ณผ, ์šฐ๋ฆฌ ๋ชจ๋‘์˜ ๋ฐฑ๊ณผ์‚ฌ์ „ ko.wikipedia.org ์‰ฝ๊ฒŒ ์–˜๊ธฐํ•˜์ž๋ฉด ์šฐ๋ฆฌ๊ฐ€ C ์–ธ์–ด๋กœ ์ž‘์„ฑ๋˜์—ˆ๋˜ ๋ช…๋ น ํ˜•์‹์˜ ์ ˆ์ฐจ ์ง€ํ–ฅ ํ”„๋กœ๊ทธ๋ž˜๋ฐ๊ณผ๋Š” ๋‹ฌ๋ฆฌ OOP๋Š” ๊ฐ์ฒด๋ผ๋Š” ๋…๋ฆฝ๋œ ๋‹จ์œ„๋กœ ํ”„๋กœ๊ทธ๋žจ์„ ํ˜•์„ฑ์‹œํ‚ค๋Š” ์Šคํ‚ฌ์ž…๋‹ˆ๋‹ค. ์ ˆ์ฐจ ์ง€ํ–ฅ ํ”„๋กœ๊ทธ๋ž˜๋ฐ์—์„œ '์ ˆ..

2022. 5. 29. 18:18

[Algorithm] - 2022 ์นด์นด์˜ค ์‹ ์ž… 1์ฐจ ์˜จ๋ผ์ธ ์ฝ”๋”ฉ ํ…Œ์ŠคํŠธ (Kakao Newbie Primary Online Coding Test) for Tech developers ๋ฌธ์ œ ํ’€์ด

๋งค๋…„ ์ด๋ค„์ง€๋Š” ์นด์นด์˜ค ์‹ ์ž… ์˜จ๋ผ์ธ ์ฝ”๋”ฉ ํ…Œ์ŠคํŠธ ๋ฌธ์ œ ํ’€์ด๋ฅผ ๋˜ ์ ๊ฒŒ ๋˜์—ˆ๋„ค์š”. ํšŒ์‚ฌ ์—…๋ฌด๋ฅผ ์ข€ ๋” ์‹ ๊ฒฝ์จ์•ผ ํ•˜๋‹ค๋ณด๋‹ˆ ๋งˆ๋ƒฅ ํ‘ธ๋Š” ๊ฒƒ์„ ๋ฏธ๋ค„๋†“๊ณ ๋งŒ ์žˆ๋‹ค ์ด์ œ์„œ์•ผ ๋ฌธ์ œ ํ’€์ด๋ฅผ ์ง„ํ–‰ํ•˜๊ฒŒ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. ์ด๋ฒˆ์—๋„ ๋จผ์ € ๋ฌธ์ œ ํ’€์ด ์ „ ํ›„๊ธฐ๋ฅผ ์ž ๊น ๋ง์”€๋“œ๋ฆฌ์ž๋ฉด ์ž‘๋…„ ๋ฌธ์ œ์— ๋น„ํ•˜์—ฌ ๋‚œ์ด๋„๊ฐ€ ๋งŽ์ด ๊ฐœ์„ ๋œ ๋ชจ์Šต์ด์—ˆ์Šต๋‹ˆ๋‹ค. ์ž‘๋…„๊ณผ ๋‹ฌ๋ฆฌ Lv 4 ๋ฌธ์ œ๋Š” ์ถœ์ œ ๋˜์ง€ ์•Š์•˜๊ณ , ๊ตฌํ˜„ ์ค‘์‹ฌ์˜ ์•ž ๋ฌธ์ œ์™€ ์ข€ ๋” ์‹ค๋ ฅ์„ ๋ณด๊ธฐ ์œ„ํ•œ Lv 3 ๋‚œ์ด๋„ ๋ฌธ์ œ 1~2๋ฌธ์ œ๋กœ ์ถ”๋ ค์ง„ ๋ชจ์Šต์ด์—ˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋Ÿผ ๋ฌธ์ œ ํ’€์ด๋ฅผ ์ง„ํ–‰ํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. Question 01. ์‹ ๊ณ  ๊ฒฐ๊ณผ ๋ฐ›๊ธฐ ๋ฌธ์ œ ์›๋ฌธ: (https://programmers.co.kr/learn/courses/30/lessons/92334) ์‹ ์ž…์‚ฌ์› ๋ฌด์ง€๋Š” ๊ฒŒ์‹œํŒ์˜ ๋ถˆ๋Ÿ‰ ์ด์šฉ์ž๋ฅผ ์‹ ๊ณ ํ•˜๊ณ  ์ฒ˜๋ฆฌ ๊ฒฐ๊ณผ๋ฅผ ๋ฉ”..

2022. 5. 22. 21:13

[FastAPI] 16. Pulumi๋ฅผ ์ด์šฉํ•ด FastAPI Serverless ํ™˜๊ฒฝ ๊ตฌ์ถ•ํ•ด๋ณด๊ธฐ

์šฐ๋ฆฌ๋Š” ์ง€๋‚œ ๊ธ€์—์„œ FastAPI, Magnum, AWS Serverless Stack(Lambda, API Gateway)์„ ์ด์šฉํ•˜์—ฌ FastAPI ์„œ๋ฒ„๋ฆฌ์Šค ํ™˜๊ฒฝ์„ ๊ตฌ์ถ•ํ–ˆ์Šต๋‹ˆ๋‹ค. 2022.05.22 - [Programming/Python] - [FastAPI] 15. FastAPI๋ฅผ Serverless๋กœ ๋ฐฐํฌํ•˜๋Š” ๋ฐฉ๋ฒ• - Mangum [FastAPI] 15. FastAPI๋ฅผ Serverless๋กœ ๋ฐฐํฌํ•˜๋Š” ๋ฐฉ๋ฒ• - Mangum ์ด๋ฒˆ ํฌ์ŠคํŠธ์—์„œ๋Š” FastAPI์™€ Serverless(์„œ๋ฒ„๋ฆฌ์Šค) ์กฐํ•ฉ์— ๋Œ€ํ•ด ์•Œ์•„๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค. ์ œ๊ฐ€ ์ดˆ๊ธฐ ์„œ๋ฒ„๋ฆฌ์Šค๋ฅผ ๋ฐฐ์› ์„ ๋•Œ๋Š” AWS์˜ Lambda๋ผ๋Š” ์„œ๋น„์Šค๊ฐ€ ๋‚˜์™”์„ ๋•Œ์˜€๋Š”๋ฐ์š”. ๋‹น์‹œ ์‚ฌ์šฉํ•  ๋•Œ๋Š” ๋ณ„๋„์˜ ํ”„ blog.neonkid.xyz ํ•˜์ง€๋งŒ AWS Lambda์™€ API..

2022. 5. 22. 00:03

[FastAPI] 15. FastAPI๋ฅผ Serverless๋กœ ๋ฐฐํฌํ•˜๋Š” ๋ฐฉ๋ฒ• - Mangum

์ด๋ฒˆ ํฌ์ŠคํŠธ์—์„œ๋Š” FastAPI์™€ Serverless(์„œ๋ฒ„๋ฆฌ์Šค) ์กฐํ•ฉ์— ๋Œ€ํ•ด ์•Œ์•„๋ณด๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค. ์ œ๊ฐ€ ์ดˆ๊ธฐ ์„œ๋ฒ„๋ฆฌ์Šค๋ฅผ ๋ฐฐ์› ์„ ๋•Œ๋Š” AWS์˜ Lambda๋ผ๋Š” ์„œ๋น„์Šค๊ฐ€ ๋‚˜์™”์„ ๋•Œ์˜€๋Š”๋ฐ์š”. ๋‹น์‹œ ์‚ฌ์šฉํ•  ๋•Œ๋Š” ๋ณ„๋„์˜ ํ”„๋ ˆ์ž„์›Œํฌ ํ•„์š”์—†์ด ํ•จ์ˆ˜์˜ ๊ตฌํ˜„๋งŒ์œผ๋กœ API ์„œ๋น„์Šค๋ฅผ ๋งŒ๋“ค ์ˆ˜ ์žˆ๋Š” Cloud Native(ํด๋ผ์šฐ๋“œ ๋„ค์ดํ‹ฐ๋ธŒ) ๊ฐœ๋ฐœ ๋ชจ๋ธ์ด์—ˆ์Šต๋‹ˆ๋‹ค. Serverless Serverless(์„œ๋ฒ„๋ฆฌ์Šค)๋ผ๋Š” ๋‹จ์–ด๋ฅผ ์ผ๋ฐ˜์ ์œผ๋กœ ํ•ด์„ํ•˜๋ฉด '์„œ๋ฒ„ ์—†๋Š” ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜', '์„œ๋ฒ„ ์—†๋Š” ์„œ๋น„์Šค'๋ผ๋Š” ๋œป์ด ๋ฉ๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ ์‹ค์ œ๋กœ ์„œ๋ฒ„๋ฆฌ์Šค๋Š” ์„œ๋ฒ„ ์—†์ด ์„œ๋น„์Šค๋ฅผ ์šด์˜ํ•˜๊ฑฐ๋‚˜ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ๋ฐฐํฌํ•˜๋Š” ๊ฒƒ์€ ์•„๋‹™๋‹ˆ๋‹ค. ์‹ค์ œ ์„œ๋ฒ„๋ฆฌ์Šค๋Š” ๊ฐœ๋ฐœ์ž๊ฐ€ ๋ณ„๋„๋กœ ์„œ๋ฒ„ ๊ด€๋ฆฌ๋ผ๋Š” ๋น„์šฉ์—†์ด ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์„ ๋นŒ๋“œํ•˜๊ณ  ์‹คํ–‰ํ•  ์ˆ˜ ์žˆ๋„๋ก ํ•˜๋Š” ๊ฐœ๋ฐœ ๋ชจ๋ธ๋กœ์จ ๋Œ€ํ‘œ์ ์œผ..

2022. 5. 16. 22:06

[Spring] Spring Advice๋กœ ์ปค์Šคํ…€ ์–ด๋“œ๋ฐ”์ด์Šค ๋งŒ๋“ค๊ธฐ

์ด๋ฒˆ ํฌ์ŠคํŠธ๋ถ€ํ„ฐ๋Š” Spring AOP ์ปดํฌ๋„ŒํŠธ๋ฅผ ์ด์šฉํ•˜์—ฌ ์‹ค์ œ Advice๋ฅผ ๋งŒ๋“ค์–ด๋ณด๊ณ , ์œ„๋น™ํ•˜๋Š” ์‹œ๊ฐ„์„ ๊ฐ€์ ธ๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. Advice Interface Advice์— ๋Œ€ํ•ด ๋‹ค์‹œ ๋ณต์Šตํ•ด๋ณด์ž๋ฉด Advice๋Š” ํŠน์ • ์กฐ์ธํฌ์ธํŠธ ์ฆ‰, ๋ฉ”์„œ๋“œ๊ฐ€ ํ˜ธ์ถœ๋˜๋Š” ์‹œ์ ์— ์‹คํ–‰ํ•  ์ฝ”๋“œ๋ฅผ ์ •์˜ํ•œ ๊ฒƒ์ž…๋‹ˆ๋‹ค. ProxyFactory ํด๋ž˜์Šค์—์„œ addAdvice ๋ฉ”์„œ๋“œ๋ฅผ ์ด์šฉํ•ด ์–ด๋“œ๋ฐ”์ด์Šค๋ฅผ ์ง์ ‘ ์ถ”๊ฐ€ํ•˜๋Š” ๋ฐฉ๋ฒ•๊ณผ Advisor ๊ตฌํ˜„์ฒด๋ฅผ addAdvice์— ์ „๋‹ฌํ•˜์—ฌ ๊ฐ„์ ‘์ ์œผ๋กœ ์ถ”๊ฐ€ํ•˜๋Š” ๋ฐฉ๋ฒ•์ด ์žˆ์—ˆ์ฃ . ๋‘ ๋ฐฉ๋ฒ•์— ์ฐจ์ด๊ฐ€ ์žˆ๋‹ค๋ฉด ์–ด๋“œ๋ฐ”์ด์Šค์™€ ๋‹ฌ๋ฆฌ Advisor๋Š” ๊ด€๋ จ PointCut๊ณผ ํ•จ๊ป˜ ์–ด๋“œ๋ฐ”์ด์Šค๋ฅผ ์ „๋‹ฌํ•œ๋‹ค๋Š” ์ ์ด ์žˆ์Šต๋‹ˆ๋‹ค. PointCut์€ ์‹ค์ œ ์–ด๋“œ๋ฐ”์ด์Šค๋ฅผ ์–ธ์ œ ์‹คํ–‰ํ• ์ง€๋ฅผ ์ •ํ•˜๋Š” AOP ์šฉ์–ด๋กœ ์–ด๋“œ๋ฐ”์ด์Šค๋ฅผ ์‹คํ–‰ํ•  ์ง€์ ์„ ์ƒ์„ธํ•˜๊ฒŒ ์ง€์ •..

2022. 5. 15. 22:37

[Spring] Spring AOP - Spring์—์„œ๋Š” AOP๋ฅผ ์–ด๋–ป๊ฒŒ ์ด์šฉํ• ๊นŒ?

์•ž์„œ ์šฐ๋ฆฌ๋Š” AOP(Aspect Oriented Programming, ๊ด€์  ์ง€ํ–ฅ ํ”„๋กœ๊ทธ๋ž˜๋ฐ)์— ๋Œ€ํ•œ ๊ธฐ๋ณธ๊ณผ ๊ฐœ๋…์— ๋Œ€ํ•ด ์•Œ์•„๋ดค์Šต๋‹ˆ๋‹ค. ๋งŒ์•ฝ ์ฝ์–ด๋ณด์ง€ ๋ชปํ–ˆ๋‹ค๋ฉด ์ด ๊ธ€์„ ์ฝ๊ธฐ ์ „ ๋ฐ˜๋“œ์‹œ ์ฝ์–ด๋ณด์‹œ๊ธธ ๊ถŒ์žฅ๋“œ๋ฆฝ๋‹ˆ๋‹ค. 2022.05.14 - [Programming/Spring] - [Spring] AOP (Aspect-Oriented Programming) ๊ธฐ๋ณธ๊ณผ ๊ฐœ๋… [Spring] AOP (Aspect-Oriented Programming) ๊ธฐ๋ณธ๊ณผ ๊ฐœ๋… Spring์—๋Š” AOP(Aspect-Oriented Programming, ๊ด€์  ์ง€ํ–ฅ ํ”„๋กœ๊ทธ๋ž˜๋ฐ)์ด๋ผ๋Š” ํ•ต์‹ฌ ๊ธฐ๋Šฅ์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. ์Œ? OOP(๊ฐ์ฒด ์ง€ํ–ฅ ํ”„๋กœ๊ทธ๋ž˜๋ฐ)๋ผ๋Š” ๊ฒƒ์€ ๋“ค์–ด๋ดค๋Š”๋ฐ, AOP๋Š” ๋ฌด์—‡์ผ๊นŒ์š”? AOP vs OOP ? ๊ด€์  ์ง€ํ–ฅ ํ”„๋กœ๊ทธ๋ž˜๋ฐ blog..

2022. 5. 14. 20:21

[Spring] AOP (Aspect-Oriented Programming) ๊ธฐ๋ณธ๊ณผ ๊ฐœ๋…

Spring์—๋Š” AOP(Aspect-Oriented Programming, ๊ด€์  ์ง€ํ–ฅ ํ”„๋กœ๊ทธ๋ž˜๋ฐ)์ด๋ผ๋Š” ํ•ต์‹ฌ ๊ธฐ๋Šฅ์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. ์Œ? OOP(๊ฐ์ฒด ์ง€ํ–ฅ ํ”„๋กœ๊ทธ๋ž˜๋ฐ)๋ผ๋Š” ๊ฒƒ์€ ๋“ค์–ด๋ดค๋Š”๋ฐ, AOP๋Š” ๋ฌด์—‡์ผ๊นŒ์š”? AOP vs OOP ? ๊ด€์  ์ง€ํ–ฅ ํ”„๋กœ๊ทธ๋ž˜๋ฐ(AOP)์€ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์—์„œ ์ฝ”๋“œ๊ฐ€ ์ค‘๋ณต๋˜๊ณ  ๊ฐ•๋ ฅํ•˜๊ฒŒ ๊ฒฐํ•ฉ๋˜์–ด ๋‹ค๋ฅธ ๋กœ์ง๊ณผ ๋ถ„๋ฆฌํ•  ์ˆ˜ ์—†๋Š” ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ๋กœ์ง๋“ค์„ ๋ณ„๋„์˜ ๊ด€์‹ฌ์‚ฌ๋กœ ๋ถ„๋ฆฌํ•˜์—ฌ ๋ชจ๋“ˆํšŒ ํ•˜๋Š” ํ”„๋กœ๊ทธ๋ž˜๋ฐ ๋ฐฉ๋ฒ•์ž…๋‹ˆ๋‹ค. ์šฐ๋ฆฌ๋Š” ๋ณดํ†ต ์ด๋Ÿฌํ•œ ๋กœ์ง์„ ๋งŒ๋‚ฌ์„ ๋•Œ ์ฝ”๋“œ๋ฅผ ๋ณต์ œํ•˜์—ฌ ์˜์กด์„ฑ์„ ๋งŒ๋“ค๊ฒŒ ๋˜๋Š”๋ฐ, AOP๋Š” ์ด๋Ÿฌํ•œ ์˜์กด์„ฑ ์—†์ด๋„ ๋™์ž‘ํ•˜๊ฒŒ ํ•ด์ค๋‹ˆ๋‹ค. ๋Œ€ํ‘œ์ ์œผ๋กœ logging ์ฝ”๋“œ๋“ค์ด ์—ฌ๊ธฐ์— ํ•ด๋‹นํ•ฉ๋‹ˆ๋‹ค. ๊ทธ๋ ‡๋‹ค๋ฉด AOP์™€ OOP๋Š” ์„œ๋กœ ๊ฒฝ์Ÿํ•˜๋Š” ๊ด€๊ณ„์ธ๊ฐ€์š”? ๊ทธ๊ฒƒ์€ ์•„๋‹™๋‹ˆ๋‹ค. ์™œ๋ƒํ•˜๋ฉด ์šฐ๋ฆฌ๋Š” OOP๋งŒ์„ ๊ฐ€์ง€๊ณ  ..

2022. 5. 5. 20:30

[Spring Data] @Transactional ์–ด๋…ธํ…Œ์ด์…˜์œผ๋กœ ๋ณด๋Š” Spring์˜ ํŠธ๋žœ์žญ์…˜ ์ด์•ผ๊ธฐ

Spring์„ ํ•œ ๋ฒˆ ์ฏค ์‚ฌ์šฉํ•ด๋ณด์…จ๋‹ค๋ฉด Transactional ์–ด๋…ธํ…Œ์ด์…˜์— ๋Œ€ํ•ด ์•Œ๊ณ ๊ณ„์‹ค ๊ฒƒ์ž…๋‹ˆ๋‹ค. ๊ทธ๋Ÿฐ๋ฐ ๋ฌด์ž‘์ • ์ผ์„ ๋• DB๋ž‘ ์—ฐ๊ฒฐํ•˜๊ณ  ๊ฐ์ฒด ๋ฐ์ดํ„ฐ๋ฅผ ์˜์†ํ•  ๋•Œ ์ด๊ฑฐ ์“ฐ๋ฉด ๋ผ. ๋ผ๊ณ  ์ƒ๊ฐํ•˜์‹œ๋Š” ๋ถ„๋“ค์ด ๊ณ„์…จ์„ ๊ฒƒ์ž…๋‹ˆ๋‹ค. ํ•˜์ง€๋งŒ ์‹ค์ œ๋กœ ์ด ์–ด๋…ธํ…Œ์ด์…˜์„ ์‚ฌ์šฉํ–ˆ์„ ๋•Œ์™€ ๊ทธ๋ ‡์ง€ ์•Š์•˜์„ ๋•Œ ์™œ ์ด๋Ÿฐ ์ฐจ์ด๊ฐ€ ๋ฐœ์ƒํ•˜๋Š”์ง€์— ๋Œ€ํ•ด ํ•œ ๋ฒˆ ์ฏค ๊ถ๊ธˆ์ฆ์„ ๊ฐ€์ ธ๋ณด์‹  ๋ถ„๋“ค์ด ๊ณ„์‹ ๋‹ค๋ฉด ์ด ๊ธ€์„ ์ฐจ๋ถ„ํžˆ ์ฝ์–ด ๋ณด์…จ์œผ๋ฉด ์ข‹๊ฒ ์Šต๋‹ˆ๋‹ค. Transaction ํŠธ๋žœ์žญ์…˜์— ๋Œ€ํ•ด์„œ๋Š” ๋‹ค๋ฅธ ๊ธ€์—์„œ๋„ ์ถฉ๋ถ„ํžˆ ์–ธ๊ธ‰๋˜์–ด ์žˆ๋Š” ๋‚ด์šฉ์ด์ง€๋งŒ ์—ฌ๊ธฐ์„œ ํ•œ ๋ฒˆ ๋” ์„ค๋ช…์„ ๋“œ๋ฆฌ๋ฉด, ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์˜ ํŠธ๋žœ์žญ์…˜์„ ์ด์•ผ๊ธฐํ•˜๋ฉฐ DBMS ํ˜น์€ ๊ทธ ์œ ์‚ฌํ•œ ์‹œ์Šคํ…œ์—์„œ ๋ฐœ์ƒํ•˜๋Š” ์—ฐ์‚ฐ๋“ค์˜ ์ƒํ˜ธ์ž‘์šฉ ๋‹จ์œ„์ž…๋‹ˆ๋‹ค. ์ข€ ๋” ์‰ฝ๊ฒŒ ์„ค๋ช…์„ ํ•ด๋ณด๋ฉด, ์šฐ๋ฆฌ๋Š” ๋ฐ์ดํ„ฐ ํ•˜๋‚˜๋ฅผ ์˜์†ํ•˜๊ฑฐ๋‚˜ ๋ณ€๊ฒฝํ•˜๊ธฐ ์œ„..

2022. 4. 24. 17:49

[FastAPI] 14. SQLAlchemy์˜ One-to-Many, Many-to-Many, Self referential relationship

์ง€๋‚œ ํฌ์ŠคํŠธ์—์„œ๋Š” ๋‹จ์ˆœ Column ๋ฐ์ดํ„ฐ์™€ ๊ทธ๋ฆฌ๊ณ , ๋‹จ์ผ ์™ธ๋ž˜ํ‚ค ํ•˜๋‚˜์˜ ๊ด€๊ณ„ ๋ฐ์ดํ„ฐ๋ฅผ Pydantic์œผ๋กœ ๋งคํ•‘ํ•˜์—ฌ Serialize/Deserialize ํ•˜๋Š” ๊ฒƒ์— ๋Œ€ํ•ด ์•Œ์•„๋ดค์Šต๋‹ˆ๋‹ค. ์ด๋ฒˆ ํฌ์ŠคํŠธ์—์„œ๋Š” Many-to-Many, One-to-Many ํ˜•ํƒœ์˜ Foreign Key๊ฐ€ ๊ฑธ๋ ค ์žˆ๋Š” ๊ด€๊ณ„ํ˜• ๋ฐ์ดํ„ฐ๋ฅผ Joinํ•ด์„œ ๊ฐ€์ ธ์˜ฌ ๋–„ ์–ด๋–ป๊ฒŒ Pydantic ๋ชจ๋ธ๊ณผ ๋งคํ•‘ํ•  ์ˆ˜ ์žˆ๋Š”์ง€์— ๋Œ€ํ•ด ์•Œ์•„๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. DB์—์„œ ๋‹จ์ˆœํ•˜๊ฒŒ ์ ‘๊ทผ ์ง€๋‚œ ํฌ์ŠคํŠธ์—์„œ ์‚ฌ์šฉํ•œ ERD๋ฅผ ๊ทธ๋Œ€๋กœ ์‚ฌ์šฉํ•ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. Category์™€ Post๊ฐ€ ์žˆ๊ณ , Post๋Š” category_id๋ฅผ ์™ธ๋ž˜ํ‚ค๋กœ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ์Šต๋‹ˆ๋‹ค. ๋”ฐ๋ผ์„œ ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋ฐ์ดํ„ฐ๋ฅผ category ํ…Œ์ด๋ธ”์ด ๊ฐ€์ง€๊ณ  ์žˆ๋Š”๊ฑด๋ฐ, ์šฐ๋ฆฌ๊ฐ€ ์ด ์ •๋ณด๋ฅผ ๋ชจ๋‘ ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค๋กœ ๊ฐ€์ ธ์˜ค๋ ค๋ฉด ์–ด๋–ป๊ฒŒ ํ•ด์•ผ ..