작성
·
128
0
안녕하세요. 테스트 오류가 나서 질문 드립니다 !
어디 부분을 수정해야 할지 모르겠습니다 ㅠㅠ
package hello.core.order;
import hello.core.acnnotation.MainDiscountPolicy;
import hello.core.discount.DiscountPolicy;
import hello.core.member.Member;
import hello.core.member.MemberRepository;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Component;
@Component
public class OrderServiceImpl implements OrderService{
private final MemberRepository memberRepository ;
private final DiscountPolicy discountPolicy ;
@Autowired
public OrderServiceImpl(MemberRepository memberRepository, @MainDiscountPolicy DiscountPolicy discountPolicy) {
this.memberRepository = memberRepository;
this.discountPolicy = discountPolicy;
}
@Override
public Order createOrder(Long memberId, String itemName, int itemPrice) {
Member member = memberRepository.findById(memberId);
int discountPrice = discountPolicy.discount(member, itemPrice);
return new Order(memberId, itemName, itemPrice, discountPrice);
}
//테스트 용도
public MemberRepository getMemberRepository() {
return memberRepository;
}
}
답변 1
0
안녕하세요. moonbomi님, 공식 서포터즈 y2gcoder입니다.
자주하는 질문(클릭) 의 @Autowired 부분을 참고해보십쇼! 해결 방법 중에서는 3번을 추천해드립니다 🙂
감사합니다.