반응형

Framework/Spring Boot 69

[Error] Could not write JSON: Java 8 date/time type `java.time.LocalDateTime` not supported by default:

There was an unexpected error (type=Internal Server Error, status=500). Could not write JSON: Java 8 date/time type `java.time.LocalDateTime` not supported by default: add Module "com.fasterxml.jackson.datatype:jackson-datatype-jsr310" to enable handling (through reference chain: java.util.ArrayList[0]->Bulletin.Board.domain.posts.Post["createdDate"]); nested exception is com.fasterxml.jackson.d..

[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..

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

전체 게시글 목록에서 각 게시글 제목 옆에 총 댓글 수를 출력한다. 첫 번째 시도) 👉 실패 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..

댓글 최신순 정렬

첫 번째 방법) @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 ..

[Error] Caused by: java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'post' available as request attribute

There was an unexpected error (type=Internal Server Error, status=500). An error happened during template parsing (template: "class path resource [templates/post/createPostForm.html]") org.thymeleaf.exceptions.TemplateInputException: An error happened during template parsing (template: "class path resource [templates/post/createPostForm.html]") Caused by: org.attoparser.ParseException: Error dur..

DTO

✨ DTO Data Transfer Object 계층간에 데이터를 전송할 때 사용한다. Contoller와 View, Controller와 Service DTO를 사용하는 이유 내부 데이터 구조를 유출하지 않는다. 유지보수가 쉬워진다. DTO를 사용하는 흐름 View에서 Contoller로부터 DTO를 받는다. Contoller에서 Service로 DTO를 보낸다. Service에서 Entity를 Controller에 보낸다. Controller에서 Entity를 DTO로 변환하고, model에 담아 View로 보낸다. DTO ➡️ Entity 또는 Entity ➡️ DTO로 변환하기 [첫 번째 방법] ModelMapper 사용 ModelMapper를 사용하면 자동으로 해줘서 편하다. [두 번째 방법] ..

[Error] Error creating bean with name 'emailConfig': Injection of autowired dependencies failed;

🎀 해결 이메일 서비스 테스트에서 생긴 에러 에러 로그를 자세히 보니 Jasypt 비밀번호 문제였다. 테스트할 sendMessage에 VM Option을 줬다. 🐝 에러 로그 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'emailConfig': Injection of autowired dependencies failed; nested exception is java.lang.IllegalStateException: either 'jasypt.encryptor.password', one of ['jasypt.encryptor.private-key-string', 'jasypt.encryptor...

JavaMailSender를 이용한 메일 전송

메일로 임시 비밀번호를 전송하는 것을 구현해보았다. implementation 'org.springframework.boot:spring-boot-starter-mail' build.gradle의 dependencies에 추가 spring.mail.host=smtp.gmail.com spring.mail.port=587 spring.mail.username=발송할이메일 spring.mail.password=비밀번호 spring.mail.properties.mail.smtp.auth=true spring.mail.properties.mail.smtp.starttls.enable=true// TLS-protected 연결 허용 application-mail.properties를 생성한 후 위의 내용을 추가했..

반응형