개발 지식
-
[Spring] javax.persistence.Id와 org.springframework.data.annotation.Id의 차이개발 지식/Spring 2024. 2. 13. 10:55
javax.persistence.Id는 관계형 DB에서 사용하고 org.springframework.data.annotation.Id는 JPA에 의해 지원되지 않는 NoSQL이나 프레임워크에서 사용된다. - redis의 경우 키 - 값의 형태로 데이터를 저장하는 NoSQL이기 때문에 org.springframework.data.annotation.Id 해당 어노테이션을 사용해야 한다. 예제 코드 - 또한 redis Repository의 경우 JpaRepository가 아닌 CrudRepository를 상속해야 한다. 예제 코드
-
[git] Personal access token 생성하는 방법개발 지식/GIT 2024. 1. 25. 12:57
- 로컬에서 특정 private Repository에 push를 하려고 할 때 권한이 없는 경우 아이디와 비밀번호를 요구하는 경우가 있는데 이 때 깃허브 아이디의 비밀번호를 입력하게 되면 해당 방식은 더 이상 사용되지 않아 인증에 실패하게 된다. 이 때 비밀번호 대신 해당 토큰을 입력하면 성공적으로 push가 된다. 생성 방법 Settings - Developer Settings - Personal access tokens - Tokens - Generate new token 버튼 클릭으로 생성이 가능하다. - private repository에 대한 권한만 부여하고 싶을 경우 맨 위의 repo를 체크하면 된다.
-
[Test] Interceptor 적용 후 기존 컨트롤러 테스트 깨짐개발 지식/Test 2024. 1. 10. 11:34
에러 로그 Parameter 0 of constructor in com.example.workingbook.interceptor.WebMvcConfig required a bean of type 'com.example.workingbook.device.repository.DeviceRepository' that could not be found. - 로그를 봤을 때 해당 인터셉터를 등록하는 설정 파일에서 DeviceRepository를 사용하고 있는데 컨트롤러 테스트에서 사용하는 @WebMvcTest에는 Repository 계층의 빈들은 등록하지 않기 때문에 발생한 문제이다. 해결 방법 1. 해당 인터셉터를 MockBean으로 대체 - 아예 인터셉터가 동작하지 않게 적용 - 이렇게 하는 경우 원래의 인터..
-
[Spring] 인텔리제이에서 active profile 설정하는법개발 지식/Spring 2024. 1. 8. 17:29
1. Edit Configurations 을 누른다. 2. Copy Configuration 버튼을 눌러 기존의 Application 실행을 복사한 뒤 Active profiles에 원하는 이름을 넣으면 된다. 참고 자료 https://lucas-owner.tistory.com/22 [IntelliJ] active profile 설정 하기 (Ultimate & Community) IntelliJ (Ultimate, Community)에서 active profile 설정 하는 방법 IntelliJ IDE를 사용해서 Spring Boot 환경에서 개발하다 보면 profile 별로 실행을 해야 할 때가 존재한다. profile 별로 실행 할 때 마다, application.ym lucas-owner.tisto..
-
[Spring] 설정 파일 여러 개 생성하여 적용하기(application.yml)개발 지식/Spring 2024. 1. 8. 15:49
- 설정 파일(.yml)을 여러 개 생성하여 특정 profile로 애플리케이션을 실행하는 경우 기본적인 application.yml 파일이 먼저 적용되고 이 후 application-{profile}.yml 파일의 설정이 덮어씌워지는 방식으로 동작하게 된다. 예를 들어, spring.security.oauth2.client.registration 설정에서 기본 application.yml 파일에서는 google, naver, kakao에 대한 설정을 해주었고 application-{profile}.yml 파일에서는 naver, kakao 설정을 해주는 경우 google은 기본 파일의 설정이 적용된다. profile 단위로 설정 파일을 분리하는 방법 1. application-{profile}.yml 방식..