일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | |||
5 | 6 | 7 | 8 | 9 | 10 | 11 |
12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 | 21 | 22 | 23 | 24 | 25 |
26 | 27 | 28 | 29 | 30 | 31 |
- jpa
- kotlin
- 스프링
- springdatajpa
- AOP
- QueryDSL
- pointcut
- db
- Servlet
- 그리디
- 백준
- Android
- java
- spring
- 스프링 핵심 기능
- 스프링 핵심 원리
- Greedy
- 자바
- transaction
- http
- Spring Boot
- SpringBoot
- 인프런
- Thymeleaf
- 김영한
- Proxy
- JDBC
- Exception
- 알고리즘
- JPQL
- Today
- Total
목록internal call (2)
개발자되기 프로젝트
앞선 방법들은 자기 자신을 주입하거나 또는 Provider 를 사용해야 하는 것 처럼 조금 어색한 모습을 만들었다. 가장 나은 대안은 내부 호출이 발생하지 않도록 구조를 변경하는 것이다. 실제 이 방법을 가장 권장한다. 1. Internal 클래스 분리 /** * 구조를 변경(분리) */ @Slf4j @Component public class CallServiceV3 { private final InternalService internalService; public CallServiceV3(InternalService internalService) { this.internalService = internalService; } public void external(){ log.info("call exter..
앞서 생성자 주입이 실패하는 이유는 자기 자신을 생성하면서 주입해야 하기 때문이다. 이 경우 수정자 주입을 사용하거나 지금부터 설명하는 지연 조회를 사용하면 된다. 스프링 빈을 지연해서 조회하면 되는데, ObjectProvider(Provider) , ApplicationContext 를 사용 1. ApplicationContext @Slf4j @Component public class CallServiceV2 { private final ApplicationContext applicationContext; public CallServiceV2(ApplicationContext applicationContext) { this.applicationContext = applicationContext; } p..