Caused by: org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'com.project.wemen.member.repository.MemberRepositoryCustom' available: expected single matching bean but found 2: memberRepositoryCustomImpl,memberRepository at org.springframework.beans.factory.config.DependencyDescriptor.resolveNotUnique(DependencyDescriptor.java:218) ~[spring-beans-6.0.12.jar:6.0.12] DependencyDescriptor.java:218 at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1395) ~[spring-beans-6.0.12.jar:6.0.12] DefaultListableBeanFactory.java:1395 at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1337) ~[spring-beans-6.0.12.jar:6.0.12] DefaultListableBeanFactory.java:1337
Caused by: org.springframework.beans.factory.NoUniqueBeanDefinitionException: No qualifying bean of type 'com.project.wemen.member.repository.MemberRepositoryCustom' available: expected single matching bean but found 2: memberRepositoryCustomImpl,memberRepository
@SpringBootTest
public class MemberRepositoryCustomImplTest {
@Autowired
MemberRepositoryCustom memberRepositoryCustom;
@Test
void getMemberEntityByAuthLoginId()
{
// loginId : practice12
// member email
// input : loginId -> output : memberEntity Instance
// checking equalTo memberEntity's email : practice@naver.com
Optional<MemberEntity> memberEntityList = memberRepository.findByAuthLoginId("practice12");
Assertions.assertThat(memberEntityList.get().getEmail()).isEqualTo("practice@naver.com");
}
}
public interface MemberRepository extends JpaRepository<MemberEntity,Long>, MemberRepositoryCustom
{
}
public interface public class MemberRepositoryCustomImpl implements MemberRepositoryCustom
{
}
MemberRepositoryCustomImplTest 에서
@Autowired MemberRepositoryCustom memberRepositoryCustom;
를 통해서 MemberRepositoryCustom을 어노테이션 주입 받고 있는 상황인데
MemberRepositoryCustom 구현체가 MemberRepository, MemberRepositoryCustomImpl 이 동시에 구현하고 Container 에 등록되어 이같은 Error 가 발생했다.
@Autowired MemberRepositoryCustom memberRepositoryCustom;
대신
@Autowired MemberRepository memberRepository;
사용하면 된다.
QueryDsl 을 어깨너머로 배우다 보니 이런 기초적인 에러를 발생시킨다. 공부가 필요해보인다!