싱글톤이 안먹히는 거같습니다 ㅠㅠ
아래는 테스트코드고 public class ConfigurationSingletonTest { @Test void configurationTest() { ApplicationContext ac = new AnnotationConfigApplicationContext(AppConfig.class); MemberServiceImpl memberService = ac.getBean("memberService", MemberServiceImpl.class); OrderServiceImpl orderService = ac.getBean("orderService", OrderServiceImpl.class); MemberRepository memberRepository = ac.getBean("memberRepository", MemberRepository.class); MemberRepository memberRepository1 = memberService.getMemberRepository(); MemberRepository memberRepository2 = orderService.getMemberRepository(); System.out.println("memberService -> memberRepository = "+ memberRepository1); System.out.println("orderService -> memberRepositiory = "+ memberRepository2); System.out.println("memberRepository = "+memberRepository); Assertions.assertThat(memberService.getMemberRepository()).isSameAs(memberRepository); Assertions.assertThat(orderService.getMemberRepository()).isSameAs(memberRepository); }} 아래는 AppConfig 코드입니다.. @Configurationpublic class AppConfig { @Bean public MemberService memberService() { System.out.println("call AppConfig.memberService"); return new MemberServiceImpl(new MemoryMemberRepository()); } @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(new MemoryMemberRepository(), new RateDiscountpolicy()); } @Bean public DiscountPolicy discountPolicy() { return new RateDiscountpolicy(); }}