분류 전체보기 645

[Error] org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'enableRedisKeyspaceNotificationsInitializer'

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'enableRedisKeyspaceNotificationsInitializer' defined in class path resource [org/springframework/session/data/redis/config/annotation/web/http/RedisHttpSessionConfiguration.class]: Invocation of init method failed; nested exception is org.springframework.data.redis.RedisConnectionFailureException: Unable to c..

[Error] java.lang.IllegalStateException: Failed to load ApplicationContext

java.lang.IllegalStateException: Failed to load ApplicationContext Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'enableRedisKeyspaceNotificationsInitializer' defined in org.springframework.session.data.redis.config.annotation.web.http.RedisHttpSessionConfiguration: Invocation of init method failed; nested exception is java.lang.NoSuchMethodErr..

[Error] org.springframework.data.redis.serializer.SerializationException

org.springframework.data.redis.serializer.SerializationException: Cannot serialize; nested exception is org.springframework.core.serializer.support.SerializationFailedException: Failed to serialize object using DefaultSerializer; nested exception is java.io.NotSerializableException: Bulletin.Board.domain.posts.Post Caused by: org.springframework.core.serializer.support.SerializationFailedExcepti..

[Thymeleaf] 게시글 상세보기에서 댓글 개수 출력

Comments 를 추가했다. 댓글들이 들어있는 commentList 리스트의 길이를 구한다. 참고 👇 https://dev-coco.tistory.com/132 Spring Boot JPA 게시판 댓글 작성 및 조회 구현하기 게시판에서 댓글은 없어선 안될 중요한 부분이라고 생각한다. 그래서 오늘은 게시판의 댓글 기능을 구현해보려 한다. 1. Entity 1-1. Comment @Builder @AllArgsConstructor @NoArgsConstructor @Getter @Table(n.. dev-coco.tistory.com https://solbel.tistory.com/1401 [thymeleaf] 타임리프 리스트/배열의 크기 구하는 방법 [thymeleaf] 타임리프 리스트/배열의 크기 구하..

FE/html 2022.07.07

전체 게시글 목록에서 각 게시글의 댓글 수 출력

전체 게시글 목록에서 각 게시글 제목 옆에 총 댓글 수를 출력한다. 첫 번째 시도) 👉 실패 comments An error happened during template parsing (template: "class path resource [templates/post/postList.html]") org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing (template: "class path resource [templates/post/postList.html]") Caused by: org.attoparser.ParseException: Exception evaluating SpringEL ex..

[JS] 댓글 작성/수정/삭제 후 비동기 방식으로 출력

3가지 방법 중 3번 방법을 사용했다. 1. 기존 댓글 리스트를 비운후 다시 DB에서 해당 글의 댓글 리스트를 가져온다. 반복문으로 하나씩 출력 https://dawitblog.tistory.com/129 AJAX로 댓글달기 기능 구현 댓글 기능을 구현해야 하는데, 댓글을 달거나 삭제할 때마다 페이지를 새로고침한다면 자원 낭비일 것이고, 사용자 입장에서도 별로 좋은 느낌은 받지 못한다. 그래서 AJAX를 사용해서 비동기(새 dawitblog.tistory.com 2. 댓글 작성에 성공하면 location.href로 요청을 보내기 댓글 리스트 부분만 갱신하면 되므로 이 방법은 비효율적이다. https://www.youtube.com/watch?v=ZzWXzj9vg44&t=1217s 3. 기존 댓글 테이블을..

FE/html 2022.07.06

수정 버튼 클릭시 알림창을 띄우고 요청 보내기

🎶 코드 수정 전 function updatePost(){ let id=document.getElementById('postId').value; let isUpdate=confirm("정말 수정하시겠습니까?"); if(isUpdate){ window.location.href="/post/detail/"+id; } } window.location.href는 GET방식으로 요청을 보낸다. 하지만, 내가 작성한 코드는 PUT방식으로 요청을 받아야했다. 🎶 코드 수정 후 function updatePost(){ let id=document.getElementById('postId').value; let isUpdate=confirm("정말 수정하시겠습니까?"); if(isUpdate){ return true; ..

FE/html 2022.06.09

댓글 최신순 정렬

첫 번째 방법) @OneToMany(mappedBy="post", fetch=FetchType.EAGER, cascade=CascadeType.REMOVE) @OrderBy("id desc") private List comment; 댓글 Comment과 M:1 관계를 맺는 Post에 @OrderBy 어노테이션 추가 Comment의 id 필드를 기준으로 내림차순한다. List comments = postRepository.findById(postId).orElseThrow(() -> new PostNotFoundException(postId)).getComment(); Post에서 comment를 가져온다. 두 번째 방법) public List getCommentList(Long postId){ List ..

[Bootstrap] class="invalid-feedback"이 작동하지 않을 때

제목 에러 메시지 유효성 검사에 실패한 필드의 메시지를 출력하려니까 출력이 안된다. ✨ 해결 첫 번째 방법) text-danger를 사용하니까 잘 동작한다. 두 번째 방법) We recommend using client-side validation, but in case you require server-side validation, you can indicate invalid and valid form fields with .is-invalid and .is-valid. Note that .invalid-feedback is also supported with these classes. referenced by : https://getbootstrap.com/docs/5.0/forms/validatio..

FE/html 2022.06.06

[Error] Request method 'DELETE' not supported

댓글 삭제하기를 구현하면서 문제가 발생했다. WARN 6520 --- [nio-8080-exec-6] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'DELETE' not supported] 댓글 삭제는 잘 된다. 하지만, 댓글 삭제 후 해당 게시글을 redirect하는데 405 에러가 뜬다. redirct할 때 DELETE 메소드로 요청을 보내는게 문제 ㅠ /post/detail/21은 댓글이 달린 해당 게시글이다. PUT, GET 메소드만 허용한다고 한다. ✨ 해결 // 삭제 @PostMapping("/delete..

Web 2022.06.04