Study/프로젝트 일지
pre_02.22
kahaha
2023. 2. 22. 20:54
02.22
진행사항 Tag클래스 및 패키지로 분할하였으며 DB저장 작업 진행
* 증상 : 서버를 실행하면 즉시 종료
에러 : UnsatisfiedDependencyException: Error creating bean with name 'questionController' defined in file
해결방법 : dto에서 Post와 Response의 변수명이 달라서 발생하는 듯 / 변수명을 일치시켜줬더니 정상 동작함
* 증상 : responseDto를 추가했더니 오류발생
에러 : constructor TagResponseDto() is already defined in class pre14.stackoverflow.tag.TagResponseDto
해결방법 : ResponseDto에서 @RequiredArgConstructor을 제거
* Question엔티티에서 아래와같이 @Builder를 사용하면
@Builder //QuestionDto.Post클래스타입 매개변수를 Question타입으로 변환하기 위함
public Question(final Long questionId,
final String title,
final String contents) {
this.questionId = questionId;
this.title = title;
this.contents = contents;
}
아래와 같이 .builder()을 사용할 수 있다.
public Question toQuestion() {
return Question.builder()
.title(title)
.contents(contents)
.build();
}
수정한 QuestionService클래스의 CreateQuestion부분
* 증상 : 컴파일에러
에러 : java.lang.NullPointerException: null
해결방법 : Service클래스 setmember()의 에러로 확인하여 수정하였음