더북(TheBook)

예제 3-100 @Trophy 애너테이션([[bean-aliases]] Trophy.java)

package com.apress.prospring5.ch3.annotated;

import org.springframework.core.annotation.AliasFor;

@Award
public @interface Trophy {

    @AliasFor(annotation = Award.class, attribute = "value")
    String name() default {};

}

 

따라서 다음과 같이 Singer 클래스를 작성하는 대신에,

예제 3-101 기존 Singer 클래스([[bean-aliases]] Singer.java)

package com.apress.prospring5.ch3.annotated;

import org.springframework.stereotype.Component;

@Component("johnMayer")
@Award(value={"grammy", "platinum disk"})
public class Singer {

    private String lyric = "We found a message in a bottle we were drinking";

    public void sing() {
        System.out.println(lyric);
    }

}
신간 소식 구독하기
뉴스레터에 가입하시고 이메일로 신간 소식을 받아 보세요.