Programming/Spring

Spring | Spring Framework ?

osean 2020. 8. 2. 22:31

๋“ค์–ด๊ฐ€๊ธฐ์— ์•ž์„œ


ํ•™์›์—์„œ Spring Framework / MyBatis / Maven ์„ ๋ฐฐ์šด์ง€ ์•ฝ ์ผ์ฃผ์ผ ์ •๋„ ์ง€๋‚ฌ๋‹ค.

์ €๋ฒˆ ์ฃผ์—๋Š” ์š”๊ตฌ์‚ฌํ•ญ ๋ถ„์„ / UML ๋“ฑ์— ๋Œ€ํ•ด ์‹œํ—˜์„ ์น˜๋ค˜๊ณ , ๋Œ์•„์˜ค๋Š” ์ฃผ์—๋Š” ์ด๋ฒˆ์ฃผ์— ๋ฐฐ์› ๋˜ ๋‚ด์šฉ๋“ค๋กœ ์‹œํ—˜์„ ๋ณผ ์˜ˆ์ •์ด๋‹ค.

์ˆ˜์—… ์‹œ๊ฐ„์— ๋ฐฐ์› ๋˜ ๋‚ด์šฉ, ์ฑ…์—์„œ ๋‚˜์™”๋˜ ๋‚ด์šฉ, ์—ฌ๋Ÿฌ ๋ธ”๋กœ๊ทธ์—์„œ ๋งํ•˜๋Š” ๋‚ด์šฉ๋“ค์„ Notion ์— ๊ฐœ์ธ์ ์œผ๋กœ ์ •๋ฆฌํ•ด๋‘์—ˆ์ง€๋งŒ, 

๋ณต์Šต ๊ฒธ ๋ธ”๋กœ๊ทธ์—๋„ ์ž‘์„ฑํ•˜๋ฉด ์ข‹์„ ๊ฒƒ ๊ฐ™์•„ ๋ช‡ ์ž ์ ์–ด๋ณด๋ ค๊ณ  ํ•œ๋‹ค.

 

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

 

(๊ทธ๋ž˜์„œ ์„ ๋ฐฐ๋‹˜๋“ค์˜ ํƒœํด์€ ์ •๋ง์ •๋ง ํ™˜์˜ํ•ฉ๋‹ˆ๋‹ค..!๐Ÿ˜ญ)

 

Spring Framework ? 


1) Framework ?

> ์†Œํ”„ํŠธ์›จ์–ด ํ”„๋ ˆ์ž„์›Œํฌ๋Š” ๋ณต์žกํ•œ ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜๊ฑฐ๋‚˜ ์„œ์ˆ ํ•˜๋Š”๋ฐ ์‚ฌ์šฉ๋˜๋Š” ๊ธฐ๋ณธ ๊ฐœ๋… ๊ตฌ์กฐ์ด๋‹ค. ์†Œํ”„ํŠธ์›จ์–ด ๊ฐœ๋ฐœ์— ์žˆ์–ด ํ•˜๋‚˜์˜ ๋ผˆ๋Œ€ ์—ญํ• ์„ ํ•œ๋‹ค.

 

2) Spring Framework ?

> ์ž๋ฐ” ํ”Œ๋žซํผ์„ ์œ„ํ•œ ์˜คํ”ˆ์†Œ์Šค ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ํ”„๋ ˆ์ž„์›Œํฌ์ด๋‹ค. ๊ฒฝ๋Ÿ‰ ์ปจํ…Œ์ด๋„ˆ๋กœ์จ ์ž๋ฐ” ๊ฐ์ฒด๋ฅผ ์ง์ ‘ ๊ด€๋ฆฌ(IoC) ํ•œ๋‹ค. ์ถ”์ƒํ™”๋œ ํŠธ๋žœ์žญ์…˜์„ ๊ด€๋ฆฌํ•  ์ˆ˜ ์žˆ๋„๋ก ์ง€์›ํ•˜๋ฉฐ, ์„ค์ • ํŒŒ์ผ(xml, java, property) ์„ ์ด์šฉํ•œ ์„ ์–ธ์ ์ธ ๋ฐฉ์‹์œผ๋กœ ์šด์˜ํ•œ๋‹ค.

 

  • Aop (Ascept Oriented Programming) | ๊ด€๊ณ„ ์ง€ํ–ฅ ํ”„๋กœ๊ทธ๋ž˜๋ฐ
  • Ioc (Inversion of Control) | ์ œ์–ด์˜ ์—ญ์ „
  • DI (Dependency Injection) | ์˜์กด์„ฑ ์ฃผ์ž…
  • MVC (Java Design Pattern > Model + View + Controller)

 

Aop | Ascept Oriented Programming


- ๊ด€๊ณ„ ์ง€ํ–ฅ ํ”„๋กœ๊ทธ๋ž˜๋ฐ

- ๊ฐ์ฒด ์ง€ํ–ฅ ๊ด€์ ์˜ ์ƒ์œ„ ๊ฐœ๋…

- ํŠธ๋žœ์žญ์…˜ / ๋กœ๊น… ๋“ฑ ๋‹ค์–‘ํ•œ ๊ธฐ๋Šฅ๋“ค๋กœ ์ด๋ฃจ์–ด์ง„ ๋ชจ๋“ˆ๋“ค์—์„œ ๊ณตํ†ต์ ์œผ๋กœ ๋“ค์–ด๊ฐ€๋Š” ๊ธฐ๋Šฅ์„ ๋ถ„๋ฆฌ

- ์œ„์˜ ๋ถ„๋ฆฌ๋ฅผ ์œ„ํ•ด ๊ฐ ๊ฐ์ฒด์˜ ๊ด€์ ์—์„œ ๋ฐ”๋ผ๋ณด๋ฉฐ, ์ข…๋‹จ๋ฉด์œผ๋กœ ์‚ฌ๊ณ ํ•˜๋Š” ํ”„๋กœ๊ทธ๋ž˜๋ฐ ๋ฐฉ์‹

 

Ioc | Inversion of Cotrol


- ์ œ์–ด์˜ ์—ญ์ „

- ์ปจํŠธ๋กค์˜ ์ œ์–ด๊ถŒ์ด ์‚ฌ์šฉ์ž๊ฐ€ ์•„๋‹Œ Spring Framework ์—๊ฒŒ ๋„˜์–ด๊ฐ„ ๊ฒƒ์„ ์˜๋ฏธ

- ๊ฐ์ฒด๋ฅผ ์ƒˆ๋กœ ์ƒ์„ฑํ•˜๊ฑฐ๋‚˜ ํŠน์ • ๊ฐ์ฒด๋ฅผ ์„ ํƒํ•˜์ง€ ์•Š๋Š”๋‹ค.

- ์‚ฌ์šฉ์ž๊ฐ€ ์ œ์–ดํ•ด์•ผ ํ•  ์‚ฌํ•ญ๋“ค์„ ๋ฌธ์„œ(๋ช…์„ธ)ํ™” ํ•˜์—ฌ Spring Framework ์— ๋“ฑ๋ก > Spring ์ด ์ž๋™์œผ๋กœ ํ•ด๋‹น ์ œ์–ด ์‚ฌํ•ญ๋“ค์„ ๊ด€๋ฆฌํ•œ๋‹ค.

- ์ธ์Šคํ„ด์Šค ์ƒ์„ฑ / ์‚ญ์ œ ๋“ฑ์„ Controller ๊ฐ€ ์ˆ˜ํ–‰ํ•œ๋‹ค.

- Object ๋Š” ์ž์‹ ์ด ์–ด๋–ป๊ฒŒ ์ƒ์„ฑ๋˜๊ณ  ์–ด๋–ป๊ฒŒ ์‚ฌ์šฉ๋˜๋Š”์ง€ ์•Œ ์ˆ˜ ์—†๋‹ค. > ์ถ”์ƒ์ ์ธ ๊ฒƒ์— ์˜์กด

- ๊ณ„์ธต ๊ฐ„์˜ ์˜์กด ๊ด€๊ณ„์˜ ๊ฒฐํ•ฉ๋„๋ฅผ ๋‚ฎ์ถ”๊ธฐ ์œ„ํ•ด ์ ์šฉ

 

DI | Dependency Injection


 

- ๊ฐ ๊ณ„์ธต ํ˜น์€ ์„œ๋น„์Šค ๊ฐ„ ์˜์กด์„ฑ์„ ์ฃผ์ž…ํ•˜๋Š” ๊ฒƒ์„ ๋œปํ•œ๋‹ค.

- Maven ์˜ pom.xml ํŒŒ์ผ ๋‚ด์— ์˜์กด์„ฑ์„ ์ถ”๊ฐ€ํ•˜๊ณ  context-servlet.xml (sts) / dispatcher-servlet.xml (IntelliJ) ํŒŒ์ผ ๋‚ด์— ์ถ”๊ฐ€ํ•œ ์˜์กด์„ฑ์„ ์‚ฌ์šฉํ•˜๊ธฐ ์œ„ํ•ด Spring ์— bean ์œผ๋กœ ๋“ฑ๋ก์„ ํ•˜๋Š” ๊ณผ์ •.

- Annotation ์„ ์ด์šฉํ•˜์—ฌ ์˜์กด์„ฑ ์ฃผ์ž… (@Autowired / @Controller / @Service / @Repository)

ex) Service ์˜ ์ฒ˜๋ฆฌ๋ฅผ ์œ„ํ•ด์„œ DAO ์— ์˜์กด -> has a ๊ด€๊ณ„

 

์ฐธ๊ณ 

๊ฐ“๋Œ€ํฌ ๋‹˜์˜ Spring ์ •์˜ ๋ฐ ํŠน์ง•
https://goddaehee.tistory.com/156

 

'Programming > Spring' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

[QueryDSL] NoSuchMethodError Trouble Shooting  (0) 2023.02.22
Criteria API  (0) 2023.01.28
Spring Bean / IoC Container / DI  (1) 2023.01.21
JPA / Persistence Context / Transactional  (2) 2023.01.14
IntelliJ | Spring MVC + Maven ํ”„๋กœ์ ํŠธ ๋งŒ๋“ค๊ธฐ (Oracle)  (0) 2020.07.26