더북(TheBook)

예제 2-13 스프링 컨텍스트에 동일한 타입의 빈 여러 개 추가하기

@Configuration
public class ProjectConfig {

    @Bean
    Parrot parrot1() {
        var p = new Parrot();
        p.setName("Koko");
        return p;
    }
 
    @Bean
    Parrot parrot2() {
        var p = new Parrot();
        p.setName("Miki");
        return p;
    } 

    @Bean
    Parrot parrot3() {
        var p = new Parrot();
        p.setName("Riki");
        return p; 
    }
} 
신간 소식 구독하기
뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.