일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- java
- Spring Boot
- transaction
- JDBC
- 스프링
- 알고리즘
- SpringBoot
- springdatajpa
- Proxy
- Greedy
- jpa
- Android
- http
- kotlin
- 인프런
- spring
- 김영한
- pointcut
- 스프링 핵심 기능
- AOP
- 자바
- 백준
- 그리디
- QueryDSL
- Exception
- JPQL
- db
- 스프링 핵심 원리
- Thymeleaf
- Servlet
- Today
- Total
목록스프링 빈 조회 (2)
개발자되기 프로젝트
가끔 해당 타입의 스프링 빈이 다~ 필요한 상황이 있다. 1. AllBeanTest @Autowired 통해 DiscountPolicy 타입에 해당하는 스프링 빈을 받고, 출력하는 service를 작성 설정 클래스는 AutoAppConfig와 DiscountService를 등록 어? DiscountService를,, 설정파일..로..? --> Component class로 등록임 Component scan에 의해 DiscountService도 스프링 빈으로 등록됨 Create a new AnnotationConfigApplicationContext, deriving bean definitions from the given component classes and automatically refreshing..
![](http://i1.daumcdn.net/thumb/C150x150/?fname=https://blog.kakaocdn.net/dn/nJJPU/btraqRghxhg/Ixz9ajT3JjmHbo402hc6gK/img.png)
원칙 : 부모 타입으로 조회하면, 자식 타입은 줄줄이 끌려나옴. 그러면 Object로 조회하면 전부 다 조회하겠네? 1. TestConfig class생성 해당 테스트에서 사용할 Configuration class public class ApplicationContextExtendsFindTest { AnnotationConfigApplicationContext ac = new AnnotationConfigApplicationContext(TestConfig.class); @Configuration static class TestConfig{ @Bean public DiscountPolicy rateDiscountPolicy(){ return new RateDiscountPolicy(); } @Bean ..