Auto-Increment(    @GeneratedValue(strategy = GenerationType.IDENTITY))를 위한 DB 수정
Software Development/Trial-and-error2024. 2. 16. 23:59Auto-Increment( @GeneratedValue(strategy = GenerationType.IDENTITY))를 위한 DB 수정

더미데이터 위에도 회원가입이 가능해야 하는데, 초창기 엔티티를 만들 때 미처 고려해주지 못했다. 이를 위해 단순히 @GeneratedValue(strategy = GenerationType.IDENTITY) 만 붙여줬는데, DB에 반영되지 않는 문제가 있었다. 수정 이후라 잘 반영되어 있지만, Auto Increment에 체크를 해줘도 다른 테이블과 제약조건이 걸린 탓에 반영이 안되는 상황. 이를 위해, 잠시 DB의 외래 키 제약조건을 비활성화 하고, 다시 활성화 해주는 작업이 필요했다. SET foreign_key_checks = 0; alter table member modify id bigint auto_increment; alter table member auto_increment = 1; SET..

비동기 메서드 테스트 코드 작성 시, DB 관련 유의점.
Software Development/Trial-and-error2024. 2. 5. 17:37비동기 메서드 테스트 코드 작성 시, DB 관련 유의점.

https://20180913.tistory.com/70 [Java Spring] 비동기 메서드에 대한 테스트코드 작성법 @SpringBootTest @ActiveProfiles("api-test") public class ActionServiceTest { @Autowired private ActionApiRepository actionApiRepository; @Autowired private ActionService actionService; // ThreadPoolTaskExecutor 빈을 생성하여, 비동기로 실행되 20180913.tistory.com @Async 어노테이션이 붙은 비동기 메서드로 DB에 데이터를 생성 혹은 삭제하는 메서드가 있었다. 이걸 테스트를 하는데, 하나의 클래스 안에서..

Software Development/Trial-and-error2024. 2. 1. 20:35[Java Spring] 비동기 메서드에 대한 테스트코드 작성법

@SpringBootTest @ActiveProfiles("api-test") public class ActionServiceTest { @Autowired private ActionApiRepository actionApiRepository; @Autowired private ActionService actionService; // ThreadPoolTaskExecutor 빈을 생성하여, 비동기로 실행되는 메소드가 실행되기 전에 테스트가 종료되는 것을 방지한다. @Autowired private ThreadPoolTaskExecutor threadPoolTaskExecutor; @Test public void testWhenFollowAction() throws InterruptedException {..

Software Development/Trial-and-error2024. 1. 29. 17:57테스트 코드를 작성하며 겪는 시행착오들

부끄럽지만, 오늘 테스트 코드를 작성하며 겪었던 황당한 실수들을 정리해보고자 한다. 1. Repository 불러올 때 @Autowired 빼먹기 @Autowired private PostCommentApiRepository postCommentApiRepository; .... 2. 연관관계에 있는 Repository 초기화 깜빡하기... @OneToMany 등의 연관관계가 명시되어 있는 Repo들은, 반드시 초기화 해줘야 한다. 추가로, A는 B와, B는 C와 연관관계가 있고, C에 대한 Repo 테스트코드를 작성하고자 한다면? 마찬가지로, A, B, C 모두 불러와야 한다. 반대로, 의존관계를 따로 설정해주지 않았을 경우 다른 레포를 초기화 해줄 필요는 없다. 3. @BeforeEach, @Befo..

Software Development/Trial-and-error2024. 1. 29. 17:45InvalidDataAccessResourceUsageException: could not prepare statement; SQL

문제 상황 특정 테이블을 만들고, 테스트코드를 작성 및 실행하던 도중(Repository 테스트) org.springframework.dao.InvalidDataAccessResourceUsageException: could not prepare statement; SQL [insert into post_comment (id, created_by, created_dt, deleted, updated_by, updated_dt, version, content, hate_count, like_count, parent_comment_id, pinned, post_id, reply_count, user_id) values (default, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?..

[Spring]  Error creating bean with name 'jwtService': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'jwt.secretKey' in value "${jwt.secretKey}"
Software Development/Trial-and-error2024. 1. 27. 21:28[Spring] Error creating bean with name 'jwtService': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'jwt.secretKey' in value "${jwt.secretKey}"

황당하게 Bean 주입이 안된다는 메시지가 자꾸 발생했다. https://oingdaddy.tistory.com/235 Spring properties 사용시 UnsatisfiedDependencyException: Could not resolve placeholder 오류 조치 Spring을 사용하면서 외부 설정 파일(properties or yml)은 필수적으로 사용된다. 하지만 이를 읽어오지 못하는 문제는 자주 직면하게 된다. 예를 들면 다음과 같은 오류다. org.springframework.beans.factory.Uns oingdaddy.tistory.com 해당 블로그를 통해 맥락을 짚을 수 있었는데, application.yml 을 통해 모든 외부설정을 관리하지 않고, application..

[문제 해결] Node.js sharp 이용, Crop 후 합성 문제
Software Development/Trial-and-error2024. 1. 12. 15:33[문제 해결] Node.js sharp 이용, Crop 후 합성 문제

AWS Lambda에서 돌아갈 이미지 크롭 API 수정을 맡게 되었다. 로직은 다음과 같았다. 1. 먼저 Image를 받아온 후, 1080으로 변환한다. 2. 사용자가 Screen 안에서 이미지를 재배치 한 것(확대/축소, 상하좌우 이동)을, Resize 한 후 Crop한다. 3. Crop 한 Image를, 검은색 여백 페이지와 합친다. 이 때 받게되는 정보는, resizedImage, offset 이고, resizedImage에서 offset은 계산되어 넘어오기 때문에, offset을 추가로 계산할 필요는 없다. 검은색 여백 페이지와 합칠 때, top, left를 offset과 resizedImage를 활용해 계산하는 것이 문제였다. 기존에 작성된 Crop에 문제는 없었고, processImage 부분..

Software Development/Trial-and-error2024. 1. 7. 00:54[Java] StringTokenizer 정수 두 개 입력 오류(NoSuchElementException)

자바로 PS를 처음 해보다보니, 여러 시행착오를 겪고 있다. 파이썬이었으면, input = sys.stdin.readline().rstrip() a,b = map(int, input().split()) 이면 끝날 일인데 ㅋ 오류를 발생시킨 코드는 다음과 같았다. class Solution { public static void main(String args[]) throws IOException { for(int test_case = 1; test_case

image