![Page 1: 주니어 개발자도 이해 할 수 있는 의존성 주입(Dependency Injection)](https://reader036.vdocuments.mx/reader036/viewer/2022081422/559cc91e1a28abeb4b8b47af/html5/thumbnails/1.jpg)
주니어 개발자도 이해 할 수 있는 의존성 주입
(Dependency Injection)2014. 11
Darion Kim
![Page 2: 주니어 개발자도 이해 할 수 있는 의존성 주입(Dependency Injection)](https://reader036.vdocuments.mx/reader036/viewer/2022081422/559cc91e1a28abeb4b8b47af/html5/thumbnails/2.jpg)
나는 누구?Darion Kim (김헌기)
디에스멘토링 연구소 수석보
자칭 통신(통합의 신, God of Integration)
https://www.facebook.com/groups/serverside (율이아빠)
![Page 3: 주니어 개발자도 이해 할 수 있는 의존성 주입(Dependency Injection)](https://reader036.vdocuments.mx/reader036/viewer/2022081422/559cc91e1a28abeb4b8b47af/html5/thumbnails/3.jpg)
이 문서를 모든 Freshman에게 바칩니다.
(for YMS, JHJ)
![Page 4: 주니어 개발자도 이해 할 수 있는 의존성 주입(Dependency Injection)](https://reader036.vdocuments.mx/reader036/viewer/2022081422/559cc91e1a28abeb4b8b47af/html5/thumbnails/4.jpg)
아름다운 JVM 세상을 못보셨으면 여기까지만 …
http://www.slideshare.net/hnki0104/bueatiful-jvm-world
![Page 5: 주니어 개발자도 이해 할 수 있는 의존성 주입(Dependency Injection)](https://reader036.vdocuments.mx/reader036/viewer/2022081422/559cc91e1a28abeb4b8b47af/html5/thumbnails/5.jpg)
Java Spring Framework 기준으로 설명하겠습니다.
원치않으시면 여기까지만…
![Page 6: 주니어 개발자도 이해 할 수 있는 의존성 주입(Dependency Injection)](https://reader036.vdocuments.mx/reader036/viewer/2022081422/559cc91e1a28abeb4b8b47af/html5/thumbnails/6.jpg)
약속드립니다.절대 어렵게 얘기하지 않겠습니다.
![Page 7: 주니어 개발자도 이해 할 수 있는 의존성 주입(Dependency Injection)](https://reader036.vdocuments.mx/reader036/viewer/2022081422/559cc91e1a28abeb4b8b47af/html5/thumbnails/7.jpg)
그럼 의존성 주입(Dependency Injection)에 대하여 시작하겠습니다.
![Page 8: 주니어 개발자도 이해 할 수 있는 의존성 주입(Dependency Injection)](https://reader036.vdocuments.mx/reader036/viewer/2022081422/559cc91e1a28abeb4b8b47af/html5/thumbnails/8.jpg)
일반적으로 우리는 객체를 이렇게 해서 생성합니다.
![Page 9: 주니어 개발자도 이해 할 수 있는 의존성 주입(Dependency Injection)](https://reader036.vdocuments.mx/reader036/viewer/2022081422/559cc91e1a28abeb4b8b47af/html5/thumbnails/9.jpg)
사람 객체 만들기머리A, 몸통, 팔, 다리 클래스 정의
사람 클래스 정의
사람 클래스 각각의 필드에 머리A, 몸통, 팔, 다리 클래스 합성
사람 클래스 안에서 머리A, 몸통, 팔, 다리 클래스의 객체를 생성하고 각각의 필드에 설정
![Page 10: 주니어 개발자도 이해 할 수 있는 의존성 주입(Dependency Injection)](https://reader036.vdocuments.mx/reader036/viewer/2022081422/559cc91e1a28abeb4b8b47af/html5/thumbnails/10.jpg)
그림으로 설명하면?
사람 클래스
머리 몸통 팔[] 다리[]
머리A클래스
몸통 클래스
팔 클래스
다리 클래스
![Page 11: 주니어 개발자도 이해 할 수 있는 의존성 주입(Dependency Injection)](https://reader036.vdocuments.mx/reader036/viewer/2022081422/559cc91e1a28abeb4b8b47af/html5/thumbnails/11.jpg)
사람 객체 생성
사람 클래스
머리 몸통 팔[] 다리[]
머리A클래스
몸통 클래스
팔 클래스
다리 클래스
몸통 객체
사람 객체
머리 몸통 팔[] 다리[]
머리A객체
팔-1객체
팔-2객체
다리-1객체
다리-2객체
![Page 12: 주니어 개발자도 이해 할 수 있는 의존성 주입(Dependency Injection)](https://reader036.vdocuments.mx/reader036/viewer/2022081422/559cc91e1a28abeb4b8b47af/html5/thumbnails/12.jpg)
왜 머리만 머리A클래스로 명명했을까요?
![Page 13: 주니어 개발자도 이해 할 수 있는 의존성 주입(Dependency Injection)](https://reader036.vdocuments.mx/reader036/viewer/2022081422/559cc91e1a28abeb4b8b47af/html5/thumbnails/13.jpg)
쉽게 이해하시라고 했습니다.
![Page 14: 주니어 개발자도 이해 할 수 있는 의존성 주입(Dependency Injection)](https://reader036.vdocuments.mx/reader036/viewer/2022081422/559cc91e1a28abeb4b8b47af/html5/thumbnails/14.jpg)
클래스 합성은 언제든지 변경될 수 있습
니다.
![Page 15: 주니어 개발자도 이해 할 수 있는 의존성 주입(Dependency Injection)](https://reader036.vdocuments.mx/reader036/viewer/2022081422/559cc91e1a28abeb4b8b47af/html5/thumbnails/15.jpg)
사람 객체 수정하기
사람 클래스의 머리 필드를 머리A 클래스에서 머리B 클래스로 변경
사람 클래스를 수정해야 함
사람 클래스 합성에 영향 발생
![Page 16: 주니어 개발자도 이해 할 수 있는 의존성 주입(Dependency Injection)](https://reader036.vdocuments.mx/reader036/viewer/2022081422/559cc91e1a28abeb4b8b47af/html5/thumbnails/16.jpg)
사람A 객체 생성
사람 클래스
머리 몸통 팔[] 다리[]
머리A클래스
몸통 클래스
팔 클래스
다리 클래스
몸통 객체
사람 객체
머리 몸통 팔[] 다리[]
머리A객체
팔-1객체
팔-2객체 다리-1
객체
다리-2객체
머리B클래스
머리B객체
![Page 17: 주니어 개발자도 이해 할 수 있는 의존성 주입(Dependency Injection)](https://reader036.vdocuments.mx/reader036/viewer/2022081422/559cc91e1a28abeb4b8b47af/html5/thumbnails/17.jpg)
의존성 주입으로 다시 설명하겠습니다.
![Page 18: 주니어 개발자도 이해 할 수 있는 의존성 주입(Dependency Injection)](https://reader036.vdocuments.mx/reader036/viewer/2022081422/559cc91e1a28abeb4b8b47af/html5/thumbnails/18.jpg)
사람 객체 만들기머리A, 몸통, 팔, 다리 클래스 정의
사람 클래스 정의
사람 클래스의 각각의 필드와 머리A, 몸통, 팔, 다리 클래스의 의존성을 정의한 Bean Context 작성
Bean Context 정보 기준으로 객체를 생성하고 의존성 주입
![Page 19: 주니어 개발자도 이해 할 수 있는 의존성 주입(Dependency Injection)](https://reader036.vdocuments.mx/reader036/viewer/2022081422/559cc91e1a28abeb4b8b47af/html5/thumbnails/19.jpg)
그림으로 설명하면?
사람 클래스
머리 몸통 팔[] 다리[]
머리A클래스
몸통 클래스
팔 클래스
다리 클래스
Bean Context<bean id= 머리, class=머리A 클래스/><bean id=몸통, class=몸통 클래스/> <bean id=팔, class=[팔 클래스/> <bean id=다리, class=[다리 클래스/> <bean id=사람, class=사람 클래스>
<property name=머리 value=머리> <property name=몸통 value=몸통> <property name=팔 value=팔> <property name=다리 value=다리>
</bean>
![Page 20: 주니어 개발자도 이해 할 수 있는 의존성 주입(Dependency Injection)](https://reader036.vdocuments.mx/reader036/viewer/2022081422/559cc91e1a28abeb4b8b47af/html5/thumbnails/20.jpg)
사람 객체 생성
사람 클래스
머리 몸통 팔[] 다리[]
머리A클래스
몸통 클래스
팔 클래스
다리 클래스
몸통 객체
사람 객체
머리A 몸통 팔[] 다리[]
머리A객체
팔-1객체
팔-2객체
다리-1객체
다리-2객체
BeanContext
![Page 21: 주니어 개발자도 이해 할 수 있는 의존성 주입(Dependency Injection)](https://reader036.vdocuments.mx/reader036/viewer/2022081422/559cc91e1a28abeb4b8b47af/html5/thumbnails/21.jpg)
사람 객체 수정하기
사람 클래스 머리 필드를 머리A 클래스에서 머리B 클래스로 변경
Bean Context를 <bean id=머리 class=머리B클래스>로 수정
사람 클래스에는 영향이 없음
![Page 22: 주니어 개발자도 이해 할 수 있는 의존성 주입(Dependency Injection)](https://reader036.vdocuments.mx/reader036/viewer/2022081422/559cc91e1a28abeb4b8b47af/html5/thumbnails/22.jpg)
그림으로 설명하면?
사람 클래스
머리 몸통 팔[] 다리[]
머리A클래스
머리B클래스
팔 클래스
다리 클래스
Context<bean id= 머리, class=머리B 클래스/><bean id=몸통, class=몸통 클래스/> <bean id=팔, class=[팔 클래스/> <bean id=다리, class=[다리 클래스/> <bean id=사람, class=사람 클래스>
<property name=머리 value=머리> <property name=몸통 value=몸통> <property name=팔 value=팔> <property name=다리 value=다리>
</bean>
몸통 클래스
![Page 23: 주니어 개발자도 이해 할 수 있는 의존성 주입(Dependency Injection)](https://reader036.vdocuments.mx/reader036/viewer/2022081422/559cc91e1a28abeb4b8b47af/html5/thumbnails/23.jpg)
이렇게 생각하시면 됩니다.
![Page 24: 주니어 개발자도 이해 할 수 있는 의존성 주입(Dependency Injection)](https://reader036.vdocuments.mx/reader036/viewer/2022081422/559cc91e1a28abeb4b8b47af/html5/thumbnails/24.jpg)
조소 만들어보셨습니까?
![Page 25: 주니어 개발자도 이해 할 수 있는 의존성 주입(Dependency Injection)](https://reader036.vdocuments.mx/reader036/viewer/2022081422/559cc91e1a28abeb4b8b47af/html5/thumbnails/25.jpg)
바로 찰흙부터 붙일수는 없습니다.
![Page 26: 주니어 개발자도 이해 할 수 있는 의존성 주입(Dependency Injection)](https://reader036.vdocuments.mx/reader036/viewer/2022081422/559cc91e1a28abeb4b8b47af/html5/thumbnails/26.jpg)
일에는 순서가 있습니다.
의존성 설정 의존성 주입의존성 설계
![Page 27: 주니어 개발자도 이해 할 수 있는 의존성 주입(Dependency Injection)](https://reader036.vdocuments.mx/reader036/viewer/2022081422/559cc91e1a28abeb4b8b47af/html5/thumbnails/27.jpg)
뼈대만 잘 만들면 언제든 다른 색깔의 찰흙으로 바꿔 붙일수 있습니다.
![Page 28: 주니어 개발자도 이해 할 수 있는 의존성 주입(Dependency Injection)](https://reader036.vdocuments.mx/reader036/viewer/2022081422/559cc91e1a28abeb4b8b47af/html5/thumbnails/28.jpg)
Black or White
![Page 29: 주니어 개발자도 이해 할 수 있는 의존성 주입(Dependency Injection)](https://reader036.vdocuments.mx/reader036/viewer/2022081422/559cc91e1a28abeb4b8b47af/html5/thumbnails/29.jpg)
이상 율이아빠였습니다.