SpringDI 흉내내기

Jimin·2022년 11월 9일
0

스프링 - fastcampus

목록 보기
16/21

변경에 유리한 코드

다형성, factory method

SportsCar car = new SportsCar();
Truck car = new Truck();

Car car = new SportsCar();
Car car = new Truck();

Map과 외부파일

Properties

(Key, Value) : (String, String)

Map

(Key, Value) : (Object, Object)


객체 컨테이너(ApplicatinoContext) 만들기

객체 컨테이너? = 저장소

자바빈 = 자바 객체, 몇가지의 조건을 만족시켜야 함


자동 객체 등록하기 - Componenet Scanning

클래스 앞에 @Component 애노테이션을 붙인다.


객체 찾기 - by Name, by Type

by Name

이름으로 찾기

by Type

타입으로 찾기


객체를 자동 연결하기

map에 저장된 객체의 iv 중에 @Autowired가 붙어 있으면,
map에서 iv 타입에 맞는 객체를 찾아서 연결(객체의 주소를 iv 저장)

@Autowired

→ byType

@Resource

→ byName

profile
https://github.com/Dingadung

0개의 댓글

관련 채용 정보