Spring Bean
Spring Bean 주입하기
Spring Bean 주입하기
2021.12.08Controller 와 Service 에서 Autowired 가 없는이유 @RequiredArgsConstructor @Service public class PostsService { private final PostsRepository postsRepository; @Transactional public Long save(PostsSaveRequestDto requestDto) { return postsRepository.save(requestDto.toEntitiy()).getId(); } } Bean 을 주입받는 방식들이 다음과 같습니다. @Autowired setter constructor 이 중 가장 권장되는 방식이 생성자(constructor) 로 주입받는 방식입니다. (@Autowired 는..
Spring - Application Context 와 @Bean
Spring - Application Context 와 @Bean
2021.07.16package hello.core; import hello.core.dicount.DiscountPolicy; import hello.core.dicount.FixDiscountPolicy; import hello.core.dicount.RateDiscountPolicy; import hello.core.member.MemberRepository; import hello.core.member.MemberService; import hello.core.member.MemberServiceImpl; import hello.core.member.MemoryMemberRepository; import hello.core.order.OrderService; import hello.core.order.OrderSe..