본문 바로가기

annotation3

TIL) @ResponseBody란 무엇인가! 오늘은 평소에 사용하지만 누군가가 @ResponseBody는 무엇이냐고 물었을 때 답할 수 있을 수준이 되기 위해 TIL을 정리해보았다. 우선 평소에 @ResponseBody를 사용한 코드를 가져와보았다. // 댓글 생성 @PostMapping("/myStudy/comment/{id}") @ResponseBody // id = myStudy의 id public CommentResponseDto createComment( @PathVariable Long id, @RequestBody CommentRequestDto requestDto, @AuthenticationPrincipal UserDetailsImpl userDetails) { return commentService.createComment(id,.. 2023. 8. 20.
TIL) @Builder 빌더패턴 (Builder Pattern) @Builder Lombok에 속하는 인터페이스 클래스를 생성한다. The field annotated with @Default must have an initializing expression; that expression is taken as the default to be used if not explicitly set during building 생성자 또는 클래스 위에 @Builder을 입력하면 빌더패턴 코드가 build 된다. 생성자 상단에 선언 시 생성자에 포함된 필드만 build 된다. @Getter @NoArgsConstructor // 생성자를 자동으로 생성 @ToString // 필드 값을 String으로 변환 , toString() 메서드 자동 생성 @Builder public cl.. 2023. 7. 14.
TIL) Spring에서 Error creating bean with name 에러 발생! Spring으로 과제 진행 중 실행시킬 때 다음과 같은 에러 메시지가 나왔다. org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'productController' defined in file [/Users/...controller/ProductController.class]: Unsatisfied dependency expressed through constructor parameter 0: Error creating bean with name 'productService' defined in file [/Users/...myselectshop/service/ProductServic.. 2023. 6. 26.