728x90
해당 옵션 적용시 해당 빈 객체 없어도 오류 안남
static class TestBean
{
@Autowired(required = false)
public void setNoBean(Member noBean1) {
System.out.println("noBean1 = " + noBean1);
}
@Autowired
public void setNoBean2(@Nullable Member noBean1) {
System.out.println("noBean1 = " + noBean1);
}
@Autowired
public void setNoBean3(Optional<Member> noBean3) {
System.out.println("noBean3 = " + noBean3);
}
}
728x90
'백엔드 > Spring(Boot)' 카테고리의 다른 글
빈 스코프 (0) | 2021.08.16 |
---|---|
Spring 클래스 초기화, 종료 (0) | 2021.08.16 |
컴포넌트 스캔 필터 (@ComponentScan) (0) | 2021.08.12 |
@ComponentScan (0) | 2021.08.12 |
ApplicationContext란 (0) | 2021.08.10 |