@Primary이란? @Primary 어노테이션은 예를 들어 클래스 A에 인터페이스 B를 선언했는데 인터페이스를 구현한 객체 2개가 존재할 경우 스프링은 어느 객체를 주입해야 하는지 알 수 없게 되는데 주입할 객체에 어노테이션을 지정하면 해당 객체가 주입이 된다. @Primary 예제인터페이스public interface SampleDAO {}인터페이스 구현 객체@Repositorypublic class SampleDAOImpl implements SampleDAO {}@Repositorypublic class EventSampleDAOImpl implements SampleDAO {}의존 객체@Service@ToString@RequiredArgsConstructorpublic class SampleSe..
Java/Spring
2023. 10. 8. 22:06
