Spring에서는 @Async와 ApplicationEventPublisher를 이용해 비즈니스 로직과 부가 로직을 자연스럽게 분리하여 비동기 처리를 구현할 수 있다.ApplicationEventPublisher란ApplicatoinEventPublisher는 Spring 내부에서 이벤트를 발행(Publish)하고 해당 이벤트를 처리하는 Listener를 찾아 호출해주는 기능이다.> Publisher는 이벤트를 던진다.> Listener는 해당 이벤트를 동기/비동기로 처리한다. [AS-IS] 회원가입 로직예시를 들어보자면 회원 가입 시 슬랙에 회원가입한 사용자가 생겼다는 알림을 보내는 코드가 있다.private User signup(AuthSignInRequestDTO request) { User ..
1. ParameterizedTest여러 개의 변수를 테스트해야 할 때 직접 입력하기보다 인자값으로 설정하여 간단하게 테스트할 수 있다.인자값을 이용하여 테스트할 때 사용한다.@ParameterizedTest는 단독으로는 사용할 수 없으며 인자값을 넣어주는 다른 어노테이션과 같이 사용할 수 있다.2. @ValueSource[as-is] private Set numbers; @BeforeEach void setUp(){ numbers = new HashSet(); numbers.add(1); numbers.add(2); numbers.add(3); } @DisplayName("1,2,3의 값이 set에 존재한다.") publ..
흔히 개발 수업 시간에서 배운 call-by-value와 call-by-reference에 대해서 배웠었다. 몇 년만에 왜 이걸 다시 공부하게 되었을까? 기존의 코드 @Getter @RequiredArgsConstructor public class Car { private Long id; private String name; private String sellingDate; private List carPartList; @AllArgsConstructor public static class CarPart { private Long partId; private String partName; private boolean isAvailable; } }데이터베이스에서 Car 타입의 리스트를 받아온다. 밑의 코드..
이를 구현하기 위해서는 먼저 카카오 디벨로퍼스에서 내 애플리케이션 만들기를 해야 합니다. 단건 결제의 구현 순서는 결제 준비하기 -> 결제 승인하기 입니다. 0. 기본값 설정하기 그 전에 필요한 APP_ADMIN_KEY와 CID 값을 .yml에 넣어 숨깁니다. kakaopay: admin-key: XXXXX cid: TC0ONETIME admin-key값은 카카오 디벨로퍼스에서 내 애플리케이션 만들기를 통해 얻을 수 있습니다. 그 다음에 위의 값들을 사용하기 위해 Component로 설정합니다. @Component public class KakaoPayProperties { public static String adminKey; public static String cid; public static St..
0. QueryDSL이란? public interface ItemRepository extends JpaRepository { @Query("select i from Item i where i.itemDetail like %:itemDetail% order by i.price desc") List findByItemDetail(@Param("itemDetail")String itemDetail); } 위의 코드와 같이 직접 Query문을 작성하게 되면 두 가지의 단점이 있습니다. 1. 문제가 발생하는 경우 런타임 시점에 알게 됩니다. 2. 하나하나 타이핑을 해야한다.. 위의 예제는 비교적 짧지만 join이 들어간 경우 여러 줄로 작성해야 했는데 그 과정에서 띄어쓰기로 인해 작동이 안되는 경우를 겪었습니다..
인텔리제이에서 실행했을 땐 모든 테스트가 성공으로 떴지만 CI를 하는 과정에서 test를 거칠 때 계속해서 실패했습니다... contextLoads() FAILDED를 시작으로 모든 테스트가 실패했습니다.. 이 문제를 해결하는 방법은 바로.. build.gradle을 수정하는 것입니다. tasks.named('test') { useJUnitPlatform() } test { useJUnitPlatform() } 수정한 후에 성공적으로 테스트가 완료된 점을 확인할 수 있습니다.
준비과정 1. S3 버킷 생성 및 정책 설정 2. access key, secret key 다운 받기 1. application-s3.properties 설정하기 cloud.aws.stack.auto=false cloud.aws.region.static=ap-northeast-2 cloud.aws.credentials.access-key=[access key] cloud.aws.credentials.secret-key=[secret key] cloud.aws.s3.bucket=[bucket name] S3 버킷에 대한 정보를 .properties나 .yml에 넣어줍니다. 2. S3Config 파일 설정 @Configuration() public class S3Config { @Value("${cloud...
프로젝트를 진행하면서 해당 데이터를 누가 생성하였는지, 언제 생성되었는지를 알아야 할 때가 있습니다. JPA에서 Auditing 기능을 제공하여 Entity가 등록된 시간, 수정된 시간, 등록한 사람. 수정한 사람을 자동으로 입력해 줍니다. 이제 이를 적용해 보겠습니다. 0. AuditorAwareImpl 생성 public class AuditorAwareImpl implements AuditorAware { @Override public Optional getCurrentAuditor() { Authentication authentication = SecurityContextHolder.getContext().getAuthentication(); String userId = ""; if(authenti..
회원가입 시 비밀번호를 PasswordEncoder를 통해 암호화하여 저장합니다. 1. build.gradle 설정 implementation 'org.springframework.boot:spring-boot-starter-security' testImplementation 'org.springframework.security:spring-security-test' 2. Bean 설정 @Configuration @EnableWebSecurity public class SecurityConfig { ... @Bean public PasswordEncoder passwordEncoder(){ return new BCryptPasswordEncoder(); } } 비밀번호를 암호화할 때 사용할 Passwor..
- Total
- Today
- Yesterday
- 괄호회전하기
- PostgreSQL
- 프로그래머스
- Android
- 운영체제
- 머신러닝
- PasswordEncoder
- 이진변환반복하기
- 정수삼각형
- 뉴스클러스터링
- 시스템콜
- 응답코드
- 최솟값구하기
- 다음큰숫자
- Auditing
- xv6
- 실패율
- AWS
- ubuntu
- 영어끝말잇기
- qemu
- OS
- 프리티어
- 백준
- RDS
- 우분투설치
- interrupt
- 최고의집합
- dp
- springboot
| 일 | 월 | 화 | 수 | 목 | 금 | 토 |
|---|---|---|---|---|---|---|
| 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 |