🛠️ 코드 Preview
ㄱㄱ
/* Book.java */
public class Book {
@Value("해리포터")
private String title;
@Value("J.K.롤링")
private String writer;
@Autowired
@Qualifier("printerA")
private Printer printer;
}
/* PrinterA.java */
public class PrinterA implements Printer{ // interface의 첫번째 구현체
@Override
public void print(String message) {
System.out.println("Printer A : " + message);
}
}
/* PrinterB.java */
public class PrinterB implements Printer{ // interface의 두번째 구현체
@Override
public void print(String message) {
System.out.println("Printer B : " + message);
}
}