BeanUtils

Spring Bean 유틸리티. ApplicationContext에서 빈 조회.

클래스 정의

@Component
class BeanUtils : ApplicationContextAware {
    override fun setApplicationContext(applicationContext: ApplicationContext)
}

Companion 메서드

getBean(name)

fun getBean(name: String): Any?

빈 이름으로 조회. 실패 시 null 반환.

getBean(type)

fun <T> getBean(type: Class<T>): T?

타입으로 빈 조회. 실패 시 null 반환 및 에러 로깅.

사용처

  • 정적 컨텍스트에서 빈 접근
  • 특수 상황 빈 주입