μ§κΈκΉμ§λ @Component annotation μ΄ λΆμ Coach type μ class κ° νλλ°μ μμλ€.
κ·Έλ λ€λ©΄, λ§μ½ μ¬λ¬κ°κ° μμμ κ²½μ°μ μ΄λ€ Bean object λ₯Ό inject ν΄μΌ ν κΉ?
Using Qualifiers
@Qualifiers annotation μ μ¬μ©ν¨μΌλ‘μ¨ λ¬Έμ λ₯Ό ν΄κ²°ν μ μλ€. Qualifier λ₯Ό ν΅νμ¬ νΉμ type μ λν Bean λ€ μ€μμ νΉμ μ΄λ¦μ κ°μ§ class λ§μ qualify, μ¦ μ격μ μ£Όλ κ²μ΄λ€.
Qualifiers - Test
μ°μ Qualifier λ₯Ό μ¬μ©νμ§ μκ³ @Component annotation μ μ¬μ©νμ¬ μΆκ°μ μΈ Bean μ μμ±ν μ΄νμ Application μ μ€νν΄λ³΄λ©΄ λ€μκ³Ό κ°λ€. μ°Έκ³ λ‘ Injection λ°©μμ Constructor Injection μΌλ‘ μ€μ νμλ€.

보면 single bean μ΄ μꡬλμ§λ§ 4κ°κ° λ°κ²¬λμλ€κ³ νλ€. μμ μλλλ‘ λμ¨ μ€λ₯μ΄λ€.
μ΄μ Qualifier λ₯Ό μ¬μ©νμ¬ μ€λ₯λ₯Ό μμ ν΄λ³΄μ.
// define a constructor for dependency injection
@Autowired
public DemoController(@Qualifier("footballCoach") Coach theCoach) {
myCoach = theCoach;
}μμ κ°μ΄ explicit ν type casting μ ν΄μ£Όλ syntax μ²λΌ @Qualifier annotation μ μ¬μ©ν΄μ£Όλ©΄ λλ€. Qualifier λ‘ μ§μ νκ³ μΆμ Bean μ class μ΄λ¦ 첫κΈμλ lower case λ‘ λ°κΎΈμ΄ μ§μ ν΄μ£Όλ©΄ λλ€.