다시 말하지만 앞서 소개한 구성 파일은 ‘4.3.1 빈 생성 시 메서드 실행하기’에서 본 구성 파일과 크게 다르지 않습니다. 주요 차이점은 init-method 애트리뷰트가 빠졌다는 것입니다. SimpleBeanWithInterface가 InitializingBean 인터페이스를 구현했으므로 스프링이 초기화 콜백으로 어느 메서드를 호출해야 할지 알기 때문에 초기화 메서드를 지정하는 추가 구성이 필요 없습니다. 예제 실행 결과는 다음과 같습니다.
빈 초기화 이름: John Mayer 나이: 39 빈 초기화 기본 가수 이름 설정 이름: Eric Clapton 나이: 72 빈 초기화 빈 구성 도중 에러 발생: Error creating bean with name 'singerThree' defined in class path resource [spring/app-context-xml.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: class com.apress.prospring5.ch4.SingerWithInterface 빈 타입에는 반드시 age 프로퍼티를 설정해야 합니다.