일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- Thymeleaf
- db
- transaction
- 스프링 핵심 원리
- jpa
- Greedy
- 알고리즘
- 인프런
- Servlet
- Spring Boot
- JDBC
- 스프링 핵심 기능
- 그리디
- spring
- springdatajpa
- Proxy
- java
- pointcut
- http
- 스프링
- 자바
- 백준
- Android
- JPQL
- 김영한
- kotlin
- QueryDSL
- SpringBoot
- Exception
- AOP
- Today
- Total
목록Di (5)
개발자되기 프로젝트
JDK 동적 프록시를 사용하면서 의존관계 주입을 할 때 어떤 문제가 발생하는지 코드로 알아보자. 1. ProxyDIAspect, Test @Slf4j @Aspect public class ProxyDIAspect { @Before("execution(* hello.aop..*.*(..))") public void doTrace(JoinPoint joinPoint){ log.info("[proxyDIAdvice] {}", joinPoint.getSignature()); } } @Slf4j @SpringBootTest(properties = {"spring.aop.proxy-target-class=false"}) //jdk 동적 프록시 @Import(ProxyDIAspect.class) public clas..
야아아압 1. AppConfig를 스프링 기반으로 전환! @Configutarion : 설정 정보에 적용 @Bean : 스프링 컨테이너에 bean으로 등록됨. 스프링 컨테이너에 등록 될 때 각 메서드의 이름으로 등록된다. @Configuration public class AppConfig { @Bean public MemberService memberService(){ return new MemberServiceImpl(memberRepository()); } @Bean public OrderService orderService(){ return new OrderServiceImpl(memberRepository(), discountPolicy()); } @Bean public MemoryMemberRe..
@Component, @Autowired을 사용하는 방법 외에도 스프링 빈으로 등록하는 다른 방법은 java로 직접 등록해주는 것이다. 1. SpringConfig class 간단하다! SpringConfig class를 만들고 아래와 같이 @Bean으로 등록해주면 된다. @Controller는 그대로 두고, @Service, @Repository는 삭제한 상태이다. @Configuration public class SpringConfig { @Bean public MemberService memberService(){ return new MemberService(memberRepository()); } @Bean public MemberRepository memberRepository(){ return..
스프링 빈을 등록하는 방법은 두 가지가 있다. - 컴포넌트 스캔 & 자동 의존관계 설정 - 자바 코드로 직접 먼저 컴포넌트 스캔에 대하여 알아보자. 1) 컴포넌트(@Component) 스캔과 자동 의존관계 설정 @Controller, @Service, @Repository 등은 모두 @Component 컴포넌트 스캔은 스프링이 시작될 때 @Component붙은 클래스를 bean으로 등록! 스프링은 컨테이너에 빈을 등록할 때 싱글톤으로 등록. 따라서 유일한 인스턴스 존재. @Autowired의 역할을 해당 bean들을 필요한 곳에 연결시키는 역할을 함. 1. @Controller @Controller public class MemberController { } 스프링이 처음 뜰 때 스프링 컨테이너가 생김 ..
실제 서비스와 과련된 로직을 개발해보자. 1. MemberService class 생성 public class MemberService { private final MemberRepository memberRepository= new MemoryMemberRepository(); /** * 회원 가입 */ public Long join(Member member){ //같은 이름이 있는 중복 회원 x validateDuplicateMember(member); memberRepository.save(member); return member.getId(); } private void validateDuplicateMember(Member member) { //컨, 알트, m =method extraction...