GithubHelp home page GithubHelp logo

efub / efub3-backend-session Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 14.0 774 KB

๐Ÿ’š ์ดํŽ 3๊ธฐ ๋ฐฑ์—”๋“œ ์„ธ์…˜ ์ˆ˜ํ–‰ ๋ ˆํฌ์ง€ํ† ๋ฆฌ

Java 100.00%

efub3-backend-session's Introduction

๐Ÿ“— EFUB 3๊ธฐ ์„ธ์…˜ ์ˆ˜ํ–‰ ๐Ÿ“—

-ํ•ด๋‹น ์„ธ์…˜ ์ฃผ์ฐจ์˜ ๋ชฉ์š”์ผ๊นŒ์ง€

efub3-backend-session-seminar

ํด๋ž˜์Šค์™€ ๊ฐ์ฒด

ํด๋ž˜์Šค
โ€ข ๊ฐ์ฒด๋ฅผ ๋งŒ๋“ค๊ธฐ ์œ„ํ•œ ์„ค๊ณ„๋„
โ€ข field(์ƒํƒœ)์™€ method(๋™์ž‘)๋กœ ๋‚˜๋‰จ
โ€ข ex. ๊ณ ์–‘์ด๋ฅผ field์™€ method๋กœ ๋‚˜๋ˆ„๊ธฐ
โ€ข field: ์ด๋ฆ„, ๋‚˜์ด, ์ฒด์ค‘
โ€ข method: ํ• ํ€ด๊ธฐ, ์•ผ์˜น

๊ฐ์ฒด (==์ธ์Šคํ„ด์Šค) โ€ข ๋ฌผ๋ฆฌ์ ์œผ๋กœ ์กด์žฌํ•˜๊ฑฐ๋‚˜ ์ถ”์ƒ์ ์œผ๋กœ ์ƒ๊ฐํ•  ์ˆ˜ ์žˆ๋Š” ๊ฒƒ ์ค‘์—์„œ ์ž์‹ ๊ณผ ๋‹ค๋ฅธ ๊ฒƒ์„ ์‹๋ณ„ ๊ฐ€๋Šฅํ•œ ๊ฒƒ
โ€ข ํด๋ž˜์Šค๋ฅผ ํ†ตํ•ด ๋งŒ๋“ค์–ด์ง„ ๊ฒƒ

#๋‹คํ˜•์„ฑ
ํ•˜๋‚˜์˜ ๊ฐ์ฒด๋‚˜ ๋ฉ”์†Œ๋“œ๊ฐ€ ์—ฌ๋Ÿฌ๊ฐ€์ง€ ๋‹ค๋ฅธ ํ˜•ํƒœ๋ฅผ ๊ฐ€์งˆ ์ˆ˜ ์žˆ๋Š” ๊ฒƒ
โ€ข Java์—์„œ ์˜ค๋ฒ„๋ผ์ด๋”ฉ, ์˜ค๋ฒ„๋กœ๋”ฉ, ํ˜•๋ณ€ํ™˜ ๋“ฑ์œผ๋กœ ๋‚˜ํƒ€๋‚ผ ์ˆ˜ ์žˆ์Œ
โ€ข ์˜ค๋ฒ„๋ผ์ด๋”ฉ: ๋ถ€๋ชจ ํด๋ž˜์Šค์— ์žˆ๋Š” ๋ฉ”์†Œ๋“œ๋ฅผ ์ž์‹ ํด๋ž˜์Šค์—์„œ ์žฌ์ •์˜ํ•˜์—ฌ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ
โ€ข ์˜ค๋ฒ„๋กœ๋”ฉ: ๊ฐ™์€ ์ด๋ฆ„์˜ ๋ฉ”์†Œ๋“œ๋ฅผ ๋งค๊ฐœ๋ณ€์ˆ˜์˜ ํƒ€์ž…์ด๋‚˜ ๊ฐœ์ˆ˜์— ๋”ฐ๋ผ ์ค‘๋ณต ์ •์˜ํ•จ์œผ๋กœ์จ ๋งค๊ฐœ๋ณ€์ˆ˜์— ๋”ฐ๋ผ ํŠน์ • ๋ฉ”์†Œ๋“œ๋ฅผ ํ˜ธ์ถœ

#์ƒ์„ฑ์ž ๊ฐ์ฒด๊ฐ€ ์ƒ์„ฑ๋  ๋•Œ ์ž๋™์œผ๋กœ ํ˜ธ์ถœ๋˜๋Š” ๋ฉ”์†Œ๋“œ
โ€ข ๊ฐ์ฒด์˜ ์ดˆ๊ธฐํ™”๋ฅผ ์œ„ํ•ด ์‚ฌ์šฉ๋จ
โ€ข ์ƒ์„ฑ์ž์˜ ์ด๋ฆ„์€ ํ•ด๋‹น ํด๋ž˜์Šค์˜ ์ด๋ฆ„๊ณผ ๊ฐ™์•„์•ผ ํ•จ
โ€ข return ํƒ€์ž…์ด ์—†์Œ
โ€ข ๋งค๊ฐœ๋ณ€์ˆ˜ ์กฐ๊ฑด์— ๋”ฐ๋ผ ์˜ค๋ฒ„๋กœ๋”ฉ ๊ฐ€๋Šฅ
โ€ข ํด๋ž˜์Šค์— ์ตœ์†Œ 1๊ฐœ๋Š” ์žˆ์–ด์•ผ ํ•จ

##Spring #container ์ธ์Šคํ„ด์Šค์˜ ์ƒ๋ช…์ฃผ๊ธฐ๋ฅผ ๊ด€๋ฆฌ
โ€ข ์ƒ์„ฑ๋œ ์ธ์Šคํ„ด์Šค๋“ค์—๊ฒŒ ์ถ”๊ฐ€์ ์ธ ๊ธฐ๋Šฅ ์ œ๊ณต
Spring Container
Spring์—์„œ ์ž๋ฐ” ๊ฐ์ฒด(Bean)๋“ค์„ ๊ด€๋ฆฌํ•˜๋Š” ๊ณต๊ฐ„
โ€ข ๊ฐ์ฒด์˜ ์ƒ์„ฑ๋ถ€ํ„ฐ ์†Œ๋ฉธ๊นŒ์ง€ ๊ฐœ๋ฐœ์ž ๋Œ€์‹  ๊ด€๋ฆฌ
โ€ข ๊ฐ ๊ฐ์ฒด ๊ฐ„์˜ ์˜์กด ๊ด€๊ณ„๋ฅผ ์—ฐ๊ฒฐ

Singleton ํŒจํ„ด
ํด๋ž˜์Šค์˜ ์ธ์Šคํ„ด์Šค๊ฐ€ ๋”ฑ 1๊ฐœ๋งŒ ์ƒ์„ฑ๋˜๋Š” ๊ฒƒ์„ ๋ณด์žฅํ•˜๋Š” ๋””์ž์ธ ํŒจํ„ด
โ€ข ๊ฐ์ฒด์˜ ๊ณต์œ ๋ฅผ ํ†ตํ•ด ๋ฉ”๋ชจ๋ฆฌ ๋‚ญ๋น„๋ฅผ ์ค„์ด๊ธฐ ์œ„ํ•ด ์‚ฌ์šฉ
ํŠน์ง•
โ€ข static ์˜์—ญ์— ๊ฐ์ฒด ์ธ์Šคํ„ด์Šค๋ฅผ ์ƒ์„ฑ
โ€ข private์œผ๋กœ new ํ‚ค์›Œ๋“œ๋ฅผ ๋ง‰์Œ
โ€ข getInstance() ํ‚ค์›Œ๋“œ๋ฅผ ํ†ตํ•ด์„œ๋งŒ ์กฐํšŒ ๊ฐ€๋Šฅ

  • ๋ฌธ์ œ์  : ๋ณต์žกํ•œ ์ฝ”๋“œ
    โ€ข ๊ตฌ์ฒด ํด๋ž˜์Šค.getInstance()๋กœ ๊ฐ์ฒด ์กฐํšŒ
    ไกธ ํด๋ผ์ด์–ธํŠธ๊ฐ€ ๊ตฌ์ฒด ํด๋ž˜์Šค์— ์˜์กดํ•จ์œผ๋กœ์จ DIP ์œ„๋ฐ˜
    โ€ข private ์ƒ์„ฑ์ž๋กœ ์ž์‹ ํด๋ž˜์Šค๋ฅผ ๋งŒ๋“ค๊ธฐ ์–ด๋ ค์›€

Bean Factory
Spring Container์˜ ์ตœ์ƒ์œ„ ์ธํ„ฐํŽ˜์ด์Šค
โ€ข Spring Bean์„ ์ƒ์„ฑํ•˜๊ณ , ๊ฐ์ฒด ์‚ฌ์ด์˜ ๋Ÿฐํƒ€์ž„ ์˜์กด๊ด€๊ณ„๋ฅผ ๋งบ์–ด์ฃผ๋Š” ์—ญํ• ์„ ํ•จ
โ€ข ์ง์ ‘์ ์œผ๋กœ ์‚ฌ์šฉํ•˜๋Š” ๊ฒฝ์šฐ๋Š” ๊ฑฐ์˜ ์—†์Œ

Bean
Spring Container๊ฐ€ ๊ด€๋ฆฌํ•˜๋Š” ์ž๋ฐ” ๊ฐ์ฒด
โ€ข Spring Container์— ์˜ํ•ด ์ƒ์„ฑ, ๊ด€๋ฆฌ๋จ
โ€ข Bean ์ด๋ฆ„์€ ํ•ญ์ƒ ๋‹ค๋ฅด๊ฒŒ ์„ค์ •ํ•ด์•ผ ํ•จ ไกธ Singleton ํŒจํ„ด ๋•Œ๋ฌธ
Bean ๊ด€๋ จ ๋ฉ”์„œ๋“œ

  1. getBeanDefinitionNames() : ์Šคํ”„๋ง์— ๋“ฑ๋ก๋œ ๋ชจ๋“  Bean ์ด๋ฆ„์„ ์กฐํšŒ
  2. getBean() : ํŠน์ • Bean์„ ์กฐํšŒํ•˜๋Š”๋ฐ ์‚ฌ์šฉ
    โ€ข ac.getBean(classType)
    โ€ข ac.getBean(beanA)
    โ€ข ac.getBean(beanA, classType)
    ไกธ Bean์ด ์กด์žฌํ•˜์ง€ ์•Š๋Š” ๊ฒฝ์šฐ, NoSuchDefinitionException ๋ฐœ์ƒ
  3. getBeansOfType() : ํŠน์ • ํƒ€์ž…์— ํ•ด๋‹นํ•˜๋Š” ๋ชจ๋“  Bean ์กฐํšŒ

IoC ์ œ์–ด์˜ ์—ญ์ „
ํ”„๋กœ๊ทธ๋žจ์˜ ์ œ์–ด ํ๋ฆ„์„ ๊ฐœ๋ฐœ์ž๊ฐ€ ์•„๋‹Œ ์™ธ๋ถ€์—์„œ ๊ด€๋ฆฌ
โ€ข ๊ฐ์ฒด์˜ ์ƒ์„ฑ๊ณผ ์†Œ๋ฉธ, ๊ฐ์ฒด ๊ฐ„์˜ ์˜์กด๊ด€๊ณ„ ์„ค์ •์„ ๋ชจ๋‘ Spring์—์„œ ์ œ์–ด
โ€ข ๊ฐ์ฒด์˜ ์˜์กด์„ฑ์„ ์—ญ์ „์‹œ์ผœ ๋ชจ๋“ˆ ๊ฐ„์˜ ์˜์กด๋„๋ฅผ ์ค„์ด๊ณ  ์œ ์—ฐํ•œ ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•จ
โ€ข IoC๊ฐ€ ์ด๋ฃจ์–ด์ง€๋Š” ๊ณต๊ฐ„ == IoC ์ปจํ…Œ์ด๋„ˆ

DI ์˜์กด์„ฑ ์ฃผ์ž…
ํด๋ž˜์Šค ์‚ฌ์ด์˜ ์˜์กด ๊ด€๊ณ„๋ฅผ Bean ์„ค์ • ์ •๋ณด๋ฅผ ๋ฐ”ํƒ•์œผ๋กœ ์ž๋™ ์—ฐ๊ฒฐํ•ด์ฃผ๋Š” ๊ฒƒ
์˜์กด์„ฑ ์ฃผ์ž… ๋ฐฉ๋ฒ•
์ƒ์„ฑ์ž ์ฃผ์ž…
โ€ข Spring์—์„œ ๊ฐ€์žฅ ๊ถŒ์žฅํ•จ
โ€ข ๋Œ€๋ถ€๋ถ„์˜ ์˜์กด๊ด€๊ณ„ ์ฃผ์ž…์€ ํ•œ ๋ฒˆ ์ผ์–ด๋‚  ๊ฒฝ์šฐ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ์ข…๋ฃŒ์‹œ๊นŒ์ง€ ์˜์กด๊ด€๊ณ„๋ฅผ ๋ณ€๊ฒฝํ•  ์ผ X
์ƒ์„ฑ์ž ์ฃผ์ž…์€ ๊ฐ์ฒด๋ฅผ ํ˜ธ์ถœํ•  ๋•Œ ๋”ฑ ํ•œ ๋ฒˆ๋งŒ ํ˜ธ์ถœ๋˜๋ฏ€๋กœ ๋ถˆ๋ณ€ํ•˜๊ฒŒ ์„ค๊ณ„ ๊ฐ€๋Šฅ
โ€ข ์ˆœ์ˆ˜ ์ž๋ฐ” ์ฝ”๋“œ๋ฅผ ํ†ตํ•ด ๋‹จ์œ„ ํ…Œ์ŠคํŠธ๋ฅผ ํ•˜๋Š” ๊ฒฝ์šฐ ์˜์กด๊ด€๊ณ„๊ฐ€ ๋ˆ„๋ฝ๋˜์—ˆ์„ ๋•Œ ์ปดํŒŒ์ผ ์—๋Ÿฌ๋ฅผ ํ†ตํ•ด ๋ฐ”๋กœ ์บ์น˜ํ•  ์ˆ˜ ์žˆ์Œ
โ€ข ์ˆœํ™˜ ์˜์กด์„ฑ ๊ฒ€์ถœ ๊ฐ€๋Šฅ (BeanCurrentlyCreationException ๋ฐœ์ƒ)
ํ”„๋ ˆ์ž„์›Œํฌ์— ์˜์กดํ•˜์ง€ ์•Š๊ณ  ์ˆœ์ˆ˜ ์ž๋ฐ” ์–ธ์–ด์˜ ํŠน์ง•์„ ๊ฐ€์žฅ ์ž˜ ์‚ด๋ฆฌ๋Š” ๋ฐฉ๋ฒ•

  • @RequiredArgsComstructor๋ฅผ ํ•จ๊ป˜ ์‚ฌ์šฉ ์‹œ ํ•„์š”ํ•œ ๊ธฐ๋Šฅ์„ ๋” ๊น”๋”ํ•˜๊ฒŒ ์‚ฌ์šฉ ๊ฐ€๋Šฅ

Lombok
๋ฐ˜๋ณต๋˜๋Š” ๋ฉ”์„œ๋“œ๋ฅผ ์–ด๋…ธํ…Œ์ด์…˜์„ ์‚ฌ์šฉํ•˜์—ฌ ์ž๋™์œผ๋กœ ์ž‘์„ฑํ•ด์ฃผ๋Š” ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ
โ€ข Java์— ์‚ฌ์šฉํ•˜๋Š” ๋ฉ”์„œ๋“œ๊ฐ€ ๋งŽ์•„์งˆ์ˆ˜๋ก ์ฝ”๋“œ๊ฐ€ ๋ณต์žกํ•ด์ง€๊ณ  ์ƒ์„ฑํ•˜๋Š”๋ฐ ๋ฒˆ๊ฑฐ๋กœ์›Œ์ง
ไกธ Lombok์„ ์‚ฌ์šฉํ•˜์—ฌ ์ฝ”๋“œ ๋‹ค์ด์–ดํŠธ
โ€ข ์–ด๋…ธํ…Œ์ด์…˜ ๊ธฐ๋ฐ˜์˜ ์ฝ”๋“œ ์ž๋™ ์ƒ์„ฑ์„ ํ†ตํ•œ ์ƒ์‚ฐ์„ฑ ํ–ฅ์ƒ
โ€ข ๋ฐ˜๋ณต ์ฝ”๋“œ ๋‹ค์ด์–ดํŠธ๋ฅผ ํ†ตํ•ด ๊ฐ€๋…์„ฑ ๋ฐ ์œ ์ง€๋ณด์ˆ˜์„ฑ ํ–ฅ์ƒ

์˜์กด์„ฑ ์ฃผ์ž… ๋ฐฉ๋ฒ•
Spring, Lombok์„ ๊ฒฐํ•ฉํ•œ ์ƒ์„ฑ์ž ์ฃผ์ž…
โ€ข @RequiredArgsConstructor๋ฅผ ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•
โ€ข Lombok ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ํ†ตํ•ด ์ƒ์„ฑ์ž๋ฅผ ์ƒ์„ฑ ์‹œ Spring ํ”„๋ ˆ์ž„์›Œํฌ๊ฐ€ ํ•ด๋‹น ์ƒ์„ฑ์ž์— @Autowired๊ฐ€ ์ƒ๋žต๋˜์—ˆ๋‹ค๋Š” ๊ฒƒ์„ ์ธ์‹ ์‹œ ์ ํ•ฉํ•œ Spring Bean ์ฃผ์ž…
โ€ข Spring 4.3๋ถ€ํ„ฐ ์‚ฌ์šฉ ๊ฐ€๋Šฅ

Lombok Annotation
์ƒ์„ฑ์ž ๊ด€๋ จ
โ€ข @NoArgsConstructor: ๋งค๊ฐœ ๋ณ€์ˆ˜๊ฐ€ ์—†๋Š” ๊ธฐ๋ณธ ์ƒ์„ฑ์ž๋ฅผ ์ƒ์„ฑ
โ€ข @RequiredArgsConstructor: final ํ•„๋“œ๋งŒ ํฌํ•จ๋œ ์ƒ์„ฑ์ž๋ฅผ ์ƒ์„ฑ
โ€ข @AllArgsConstructor: ๋ชจ๋“  ํ•„๋“œ๋ฅผ ํฌํ•จํ•œ ์ƒ์„ฑ์ž๋ฅผ ์ƒ์„ฑ

Lombok Annotation
๋ฉ”์„œ๋“œ ๊ด€๋ จ
โ€ข @Getter/@Setter: Getter/Setter๋ฅผ ์ž๋™์œผ๋กœ ์ƒ์„ฑ
โ€ข @toString: toString ๋ฉ”์„œ๋“œ๋ฅผ ์ž๋™์œผ๋กœ ์ƒ์„ฑ
โ€ข @EqualsAndHashCode: equals, hashCode๋ฅผ ์ž๋™์œผ๋กœ ์ƒ์„ฑ

Lombok Annotation
๋นŒ๋” ํŒจํ„ด
โ€ข @Builder: ๋ฉ”์„œ๋“œ ์ฒด์ด๋‹์„ ์ด์šฉํ•˜๋Š” static ๋ฉ”์„œ๋“œ builder๋ฅผ ์ƒ์„ฑ
ํ†ตํ•ฉ ๊ธฐ๋Šฅ
โ€ข @Data: @ToString, @EqualsAndHashCode, @Getter, @Setter, @RequiredArgsConstructor๋ฅผ ํ•œ๊บผ๋ฒˆ์— ์ œ๊ณต

efub3-backend-session's People

Contributors

doleebest avatar hannah0226 avatar june0216 avatar rovemin avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.