본문 바로가기

Spring/boot10

spring-boot, jpa, h2 환경에서 select for update (lock) 사용 방법 정리 source 는 Github 에 있습니다. spring boot h2 환경에서 jpa 명시적 락 사용하는 예제 spring boot h2 환경에서 select for update 를 사용하는 방법에 대해 정리했습니다. 결론부터 얘기하면 repository interface 에 메소드에 @Lock(LockModeType.PESSIMISTIC_WRITE) 선언하면 select for update 가 설정 됩니다. 예제에 대해 간략하게 설명하면 deposit(입금), withdraw(인출) 기능이 있으며, 여러 요청이 들어왔을 때, 동시성이 보장되는지 확인합니다. package com.example.jpa.api; import com.example.jpa.dto.BankAccountRequest; import.. 2021. 12. 21.
spring 과 spring-boot 관계 spring 과 spring-boot 관계 spring 은 IOC, DI, PSA 개념을 통해 만들어진 프레임워크 이다. spring-boot 는 spring 을 도와주기 위해 나온 개념이며. 도와주는 개념으로는 starter 와 AutoConfiguration 이 있다. spring-boot starter, AutoConfiguration starter 는 말 그대로 예제라고 이해하면 된다. 여러 예제들에 대한 탬플릿을 제공해서 개발 리소스를 줄이는거지. AutoConfiguration 은 자동으로 환경구성을 해준다는 것이다. 특정 파일에 들어있는 설정을 읽어 bean 설정이나 spring 관련 설정을 자동으로 해줌. 마찬가지로 spring 을 도와주는 개념이지. 2020. 11. 11.
@SpringBootApplication 어노테이션이란? @SpringBootApplication 어노테이션이란? ComponentScan, SpringBootConfiguration, EnableAutoConfiguration 으로 이루어 짐. @ComponentScan root 패키지에서 빈검색을 진행한다. @SpringBootApplication 이 선언된 클래스의 패키지를 루트 패키지라 생각하면 됨. @Component, @Bean, @Service 등 @EnableAutoConfiguration 미리 정의되어 있는 빈을 등록해준다. 미리 정의되어 있는 빈은 Spring-boot-autoconfigure 외부 라이브러리에 spring.factoires 에 등록돼있음. @SpringBootConfiguration SpringBoot 의 @Configura.. 2020. 10. 18.
spring boot 로그인 실패 시 후속 작업 (리다이렉트) spring boot 로그인 실패 시 후속 작업 (리다이렉트) AuthenticationFailureHandler implements 한 후, @Component 달아주면 됨. redirect 를 아래와 같이 하면 contextRootPath + "/login" 으로 redirect 가 됨. @Component public class AuthenticationFailureHandlerImpl implements AuthenticationFailureHandler { @Override public void onAuthenticationFailure(HttpServletRequest request, HttpServletResponse response, AuthenticationException e) thro.. 2020. 10. 5.