<bean /> 엘리먼트의 autowire 속성을 사용하여 bean들을 자동으로 묶을 수 있습니다. autowire에 지정할 수 있는 값은 다섯가지가 있습니다.

no : 기본값입니다. autowire를 사용하지 않겠다는 겁니다.
byName :  bean의 property 이름으로 다른 bean을 찾아서 연결합니다.
byType : bean의 property 타입으로 다른 bean을 찾아서 연결합니다. 같은 type의 bean이 여러개면 에러가 발생합니다.
constuctor : byType과 비슷한데 생성자에 있는 인자들의 Type으로 찾아서 연결합니다.
autodetect : constuctor 또는 byType으로 찾게 됩니다. default 생성자가 있으면 byType으로 찾는다는 군요.

명시적으로 <property /> 나 <constructor-arg /> 를 사용하여 종속성을 적어 줄 경우에는 autowiring으로 연결된 종속성을 overriding 합니다.

장점
1. configuration 파일의 크기를 줄여 줍니다.
2. 객체가 변하거나 추가 될 때 설정 파일의 많은 변경이 필요하지 않습니다.

단점
1. 너무 매직 스러움.
2. wiring 정보를 감춰져서 문서화 하는 도구에서 알아채질 못합니다.
3. type으로 wiring할 경우 애매한 상황이 조금이라도 발생하면 명시적으로 적어줘야 합니다.

Email 클래스를 추가하고 Member 당 하나의 Email 레퍼런스를 가지고 있습니다.

    <bean id="email" class="beanConfiguration.Email">
        <property name="type" value="google" />
        <property name="address" value="myemail@gmail.com" />
    </bean>

    <bean id="keesun5" class="beanConfiguration.Member" autowire="byName" />

Member 클래스에 setEmail(Email email) 메소드가 있기 때문에 email 이라는 이름의 bean을 찾아서 자동으로 엮어 줍니다.

    @Test public void autowiringByName(){
        Member keesun = (Member) bf.getBean("keesun5");
        Email email = keesun.getEmail();
        assertEquals("google", email.getType());
        assertEquals("myemail@gmail.com", email.getAddress());
    }