소개
게시글
질문&답변
질문 있습니다!
바쁘실텐데 답변해주셔서 감사합니다!!
- 0
- 3
- 268
질문&답변
질문 있습니다!
자꾸 질문드려 죄송합니다.. 혹시 밑처럼 작성하면 될까요?? package hello.core; import hello.core.discount.DiscountPolicy; import hello.core.discount.RateDiscountPolicy; import hello.core.member.*; import hello.core.order.OrderService; import hello.core.order.OrderServiceImpl; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import java.util.HashMap; @Configuration public class AppConfig { @Bean public MemoryMemberRepository memorymemberRepository() { return new MemoryMemberRepository(getMap()); } @Bean public HashMap getMap() { return new HashMap(); } @Bean public MemberService memberService() { System.out.println("call AppConfig.memberService"); return new MemberServiceImpl(memberRepository()); } @Bean public MemberRepository memberRepository() { System.out.println("call AppConfig.memberRepository"); return new MemoryMemberRepository(); } @Bean public OrderService orderService() { System.out.println("call AppConfig.orderService"); return new OrderServiceImpl(memberRepository(), discountPolicy()); } @Bean public DiscountPolicy discountPolicy() { return new RateDiscountPolicy(); } }
- 0
- 3
- 268