• 카테고리

    질문 & 답변
  • 세부 분야

    백엔드

  • 해결 여부

    미해결

@Autowired 필드 명, @Qualifier, @Primary 강의중인데요

23.12.16 22:12 작성 조회수 204

0

@Component
//@RequiredArgsConstructor
public class OrderServiceImpl implements OrderService {

    private final MemberRepository memberRepository;
    private final DiscountPolicy discountPolicy;

    @Autowired
    public OrderServiceImpl(MemberRepository memberRepository, DiscountPolicy rateDiscountPolicy) {
        this.memberRepository = memberRepository;
        this.discountPolicy = rateDiscountPolicy;
    }

2:50초 쯤에서 DiscountPolicy 의 변수를 rateDicountPolicy 로 변경을 하는 내용이 나오거든요

그리고 테스트를 돌리는데 성공하시더라구요 그런데 저는 여기서 아래에러가 발생해서요

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'orderServiceImpl' defined in file [C:\Users\kkk\Downloads\core\out\production\classes\hello\core\order\OrderServiceImpl.class]: Unsatisfied dependency expressed through constructor parameter 1: No qualifying bean of type 'hello.core.discount.DiscountPolicy' available: expected single matching bean but found 2: fixDiscountPolicy,rateDiscountPolicy

매칭이 안된것 같은데 어떻게 해야 할지 문의 드립니다.

답변 1

답변을 작성해보세요.

0

OMG님의 프로필

OMG

2023.12.16

안녕하세요. 행복님, 공식 서포터즈 OMG입니다.

 

스프링부트 3.2.x에서 발생하는 상황으로 보이네요 😀

자주하는 질문을 참고해주세요^^

https://docs.google.com/document/d/1j0jcJ9EoXMGzwAA2H0b9TOvRtpwlxI5Dtn3sRtuXQas/edit#heading=h.b1yk4ued1pxo

 

감사합니다.