일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
- 인프런
- 알고리즘
- Servlet
- jpa
- pointcut
- Spring Boot
- Thymeleaf
- SpringBoot
- transaction
- 스프링
- 백준
- Greedy
- 자바
- 김영한
- spring
- springdatajpa
- QueryDSL
- 스프링 핵심 원리
- http
- 스프링 핵심 기능
- 그리디
- Exception
- kotlin
- AOP
- Android
- Proxy
- JDBC
- db
- JPQL
- java
- Today
- Total
목록bean (4)
개발자되기 프로젝트
1. bean 스프링 전용 포인트컷 지시자, 빈의 이름으로 지정한다 스프링 빈의 이름으로 AOP 적용 여부를 지정한다. bean(orderService) || bean(*Repository) * 과 같은 패턴을 사용할 수 있다. 2. Test @Slf4j @Service public class OrderService { private final OrderRepository orderRepository; public OrderService(OrderRepository orderRepository) { this.orderRepository = orderRepository; } public void orderItem(String itemId) { log.info("[orderService] 실행"); orde..
1. 일반적인 스프링 빈 등록 public class BasicTest { @Test void basicConfig (){ //스프링 컨테이너 ApplicationContext applicationContext = new AnnotationConfigApplicationContext(BasicConfig.class); //A는 빈으로 등록됨. A a = applicationContext.getBean("beanA", A.class); a.helloA(); //B는 스프링 빈으로 등록되지 않음. Assertions.assertThrows(NoSuchBeanDefinitionException.class, () -> applicationContext.getBean(B.class)); } @Slf4j @Conf..
검증 기능을 지금처럼 매번 코드로 작성하는 것은 귀찮음... 특히 특정 필드에 대한 검증 로직은 대부분 빈 값인지 아닌지, 특정 크기를 넘는지 아닌지와 같이 매우 일반적 로직임. ??? : 그러면 @Annotation으로 처리해보자. public class Item { private Long id; @NotBlank private String itemName; @NotNull @Range(min = 1000, max = 1000000) private Integer price; @NotNull @Max(9999) private Integer quantity; //... } 1. Bean Validation 먼저 Bean Validation은 특정한 구현체가 아니라 Bean Validation 2.0(JSR..
@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..