전체 글

전체 글

    [Trouble Shooting] Web server failed to start. Port 8080 was already in use

    [Trouble Shooting] Web server failed to start. Port 8080 was already in use

    개발 환경 Build : Gradle SpringBoot : 2.7.5 Java : 11 OS : Mac 발생 Description: Web server failed to start. Port 8080 was already in use. Action: Identify and stop the process that's listening on port 8080 or configure this application to listen on another port. > Task :OneyearfourcutApplication.main() FAILED 원인 실행시키려는 애플리케이션의 Port가 이미 사용되고 있어 충돌이 발생하여 위와 같은 에러가 발생한 것이다. 해결 방법 1. 기존 Port 종료 해당 Port를 ..

    [SpringBoot] AWS S3 파일(이미지) 업로드 및 삭제하기 구현

    [SpringBoot] AWS S3 파일(이미지) 업로드 및 삭제하기 구현

    개발 환경 Build : Gradle SpringBoot : 2.7.5 Java : 11 OS : Mac 요구사항 client로부터 form-data의 이미지 파일을 요청받으면 해당 이미지를 S3 버킷에 업로드한 뒤 DB에 버킷의 경로를 저장하려고 함. 이미지는 1개의 이미지를 요청 및 업로드함. 구현 - AWS 관련(버킷 생성 등) 설정은 프로젝트가 끝난 뒤 정리할 예정 의존성 추가하기 https://github.com/awspring/spring-cloud-aws // AWS S3 Upload implementation 'io.awspring.cloud:spring-cloud-starter-aws:2.4.2' S3 관련 환경변수 설정하기(yml) cloud: aws: credentials: acces..

    [SpringBoot] MockMvc - multipart() POST외 다른 HTTPMethod 사용하기

    개발 환경 Build : Gradle SpringBoot : 2.7.5 Java : 11 OS : Mac 요구사항 RestDocs API 문서화를 위해 MockMvc를 이용하여 Controller 테스트 코드를 작성해야 함. 테스트할 코드는 form-data로 이미지 파일과 텍스트를 받아 리소스를 수정하는 메서드(PATCH) 따라서 MockMvc.perform으로 진행할 때 multipart()를 사용해서 테스트를 진행해야 하는데, multipart()는 기본적으로 POST로 하드 코딩되어 있음. // MockMvcRequestBuilders /** * Create a {@link MockMultipartHttpServletRequestBuilder} for a multipart request, * us..

    [TroubleShooting] SpringBoot Controller Test - MockMvc 302 Found, 403 Forbidden

    [TroubleShooting] SpringBoot Controller Test - MockMvc 302 Found, 403 Forbidden

    개발 환경 Build : Gradle SpringBoot : 2.7.5 Java : 11 OS : Mac 발생 - 403 Forbidden RestDocs를 사용하여 API 문서화 작업을 하려고 Controller에서 테스트 코드를 작성 후 테스트를 진행하였고, 403 Forbidden 에러가 발생했다. @WebMvcTest(controllers = ArtworkController.class) @MockBean({JpaMetamodelMappingContext.class, ClientRegistrationRepository.class}) @AutoConfigureRestDocs public class ArtworkControllerTest { @Autowired private MockMvc mockMvc..

    [Trouble Shooting] git pull - merge 실패 "fatal: Need to specify how to reconcile divergent branches."

    [Trouble Shooting] git pull - merge 실패 "fatal: Need to specify how to reconcile divergent branches."

    발생 작업 공용 브랜치 dev-be로부터 작업할 브랜치를 생성 후 작업함. 작업 후 커밋하기전 dev-be의 작업 전 버전과 작업 후 버전이 차이가 있는 상황. 로컬에서 최신 dev-be를 pull한 다음 충돌나는 부분을 해결 후 커밋하려고 했는데, pull하는 과정에서 아래와 같은 이슈가 발생함. 원인 You have divergent branches and need to specify how to reconcile them. fatal: Need to specify how to reconcile divergent branches. 현재 Local의 dev-be 버전과 Remote의 dev-be의 버전(분기)가 달라 pull할 때 merge가 되어야 하는데 pull 전략이 따로 지정되어 있지 않아 위와..

    [SpringDataJPA] 쿼리메서드 참조 객체의 필드 사용

    [SpringDataJPA] 쿼리메서드 참조 객체의 필드 사용

    개발 환경 Build : Gradle SpringBoot : 2.7.5 Java : 11 OS : Mac 요구사항 특정 GalleryId를 가진 작품(Artwork)List를 생성시간 기준 내림차순으로 응답하는 로직 즉, FindAll + 특정 FK(GalleryId)를 가진 Artwork만 조회하는 기능 + 정렬 필요 조건 Gallery : Artwork = 1:N 매핑 // Auditable에는 생성시간과 수정시간이 들어있음. // Artwork Entity @Entity public class Artwork extends Auditable { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) private Long artworkId; ... @Man..

    [Trouble Shooting] error: Your local changes to the following files would be overwritten by merge:

    [Trouble Shooting] error: Your local changes to the following files would be overwritten by merge:

    발생 A 브랜치에서 커밋한 뒤 B 브랜치로 변경하려고 하는데 다음과 같은 erorr가 발생함. wk@MacBookm1-Pro seb40_main_025 % git switch -t origin/Feat/#37 error: Your local changes to the following files would be overwritten by checkout: server/oneyearfourcut/src/test/java/com/codestates/mainproject/oneyearfourcut/artwork/repository/ArtworkRepositoryTest.java Please commit your changes or stash them before you switch branches. Abort..

    [Trouble Shooting] 한글 데이터 POST 요청 시 AxiosError(500)

    [Trouble Shooting] 한글 데이터 POST 요청 시 AxiosError(500)

    요약 회원가입 시 한글 데이터로 가입 요청 -> 500 에러 (영어 데이터로 가입 요청 -> 성공) Spring 로그 확인 : DB에 요청받은 회원 데이터를 저장(Repository - save())할 때 다음과 같은 에러가 발생함. ERROR 1366 (HY000): Incorrect string value: '\xEC\x9D\xB4\xEB\xAF\xB8...' for column 'name' at row 1 DB에 한글 데이터 저장 시 문제가 발생 -> 인코딩 문제 데이터베이스 인코딩 UTF-8로 설정 후 해결 완료 로컬 환경(인텔리제이 + jpa + mysql)에서 진행하다가 배포 후 저런 에러를 만나니.. 거의 3시간가량 삽질.... 좋은 경험이었다.. 발생 Pre Project를 진행하며 배포 ..