NoUniqueBeanDefinitionException 에러 ..
넵 OrderService 인터페이스 package hello.core.order; public interface OrderService { Order createOrder(Long memberId, String itemName, int itemPrice); } OrderServiceImpl 클래스 package hello.core.order; import hello.core.discount.DiscountPolicy; import hello.core.discount.FixDiscountPolicy; import hello.core.discount.RateDiscountPolicy; import hello.core.member.Member; import hello.core.member.MemberRepository; import hello.core.member.MemoryMemberRepository; import lombok.RequiredArgsConstructor; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; //@RequiredArgsConstructor //lombok 생성자주입 (final 붙은 필드를 가지고 생성자를 자동으로 만들어준다) @Component public class OrderServiceImpl implements OrderService{ //필드주입 // @Autowired private MemberRepository memberRepository; // // @Autowired private DiscountPolicy discountPolicy; private final MemberRepository memberRepository; private final DiscountPolicy discountPolicy; //생성자 주입 @Autowired // 생성자 1개일시 쓰지않아도 됨 public OrderServiceImpl(MemberRepository memberRepository, DiscountPolicy rateDiscountPolicy) { System.out.println("생성자호출"); this.memberRepository = memberRepository; this.discountPolicy = rateDiscountPolicy; } //수정자 주입 // @Autowired // public void setMemberRepository(MemberRepository memberRepository){ // this.memberRepository = memberRepository; // } // // @Autowired // public void setDiscountPolicy(DiscountPolicy discountPolicy){ // this.discountPolicy = discountPolicy; // } //메소드 주입입 // @Autowired // public void init(MemberRepository memberRepository, 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; } }