org.springframework.beans.factory.UnsatisfiedDependencyException : Error creating bean with name 'filmServiceImpl' defined in file [경로]: Unsatisfied dependency expressed through constructor parameter 1; nested exception is org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type '-경로.Movie' available: expected single matching bean but found 2: comedyMovie, RomanceMovie
@Component
@Primary
public class ComedyMovie implements Movie {
...
}
@Component
@Qualifier("mainMovie")
public class ComedyMovie implements Movie {
...
}
@Component
@Qualifier("subMovie")
public class RomanceMovie implements Movie {
...
}
@Component
public class filmServiceImpl implements filmService {
private final MemberRepository memberRepository;
private final Movie movie;
@Autowired
public OrderServiceImpl(MemberRepository memberRepository, @Qualifier("mainMovie") Movie movie) {
this.memberRepository = memberRepository;
this.movie = movie;
}
...
}
@Component
public class filmServiceImpl implements filmService {
private final MemberRepository memberRepository;
private final Movie movie;
@Autowired
public OrderServiceImpl(MemberRepository memberRepository, Movie comedyMovie) {
this.memberRepository = memberRepository;
this.movie = comedyMovie;
}
...
}