HomeAboutMeBlogGuest
© 2025 Sejin Cha. All rights reserved.
Built with Next.js, deployed on Vercel
[New] 타일러팀
[New] 타일러팀
/
🐣
이수연
/
4/6 : 의존성주입, 생명주기

4/6 : 의존성주입, 생명주기

Created
Apr 5, 2022 05:24 AM
Tags
📎
의존성주입, 생명주기

의존성주입 3가지 방법

  1. 생성자주입
    1. final불일 수 있음(final은 선언과 초기화가 같이 일어나야하지만 필드일때는 생성자로는 허용)
    2. 불변, 필수성질을 갖게할 수 있음
    3. 잘못되면 컴파일에러가 나기때문에 오류를 잡아줌
  1. 수정자주입
    1. final 붙일 수 없음
    2. 중간에 수정이 필요한경우
    3. 실수로 바꿀수 있기 때문에 권장 x
  1. 필드주입
    1. final을 붙일수 없음
    2. 간편함
    3. 스프링같은 DI프레임워크없이 의존성을 직접 주입해주기 어려움
 
  • 공식문서
Core Technologies
There are pros and cons for considering validation as business logic, and Spring offers a design for validation (and data binding) that does not exclude either one of them. Specifically, validation should not be tied to the web tier and should be easy to localize, and it should be possible to plug in any available validator.
Core Technologies
https://docs.spring.io/spring-framework/docs/6.0.0-SNAPSHOT/reference/html/core.html#beans-factory-lifecycle-initializingbean
 
  • ApplicationContext로는 close()구현 못함
  • AnnotationConfigApplicationContext
이 여러 인터페이스를 구현하는데 그중에 ApplicationContext도 있고 다른 것들도 있는데 다른것(Closeable)에서 close가 연관된것이기 때문