Error

com.fasterxml.jackson.databind.exc.InvalidDefinitionException

ewok 2023. 4. 1. 18:43

글 수정 기능을 만들던 중 아래와 같은 에러가 발생했다.

 

 

package com.ewok.springbootproject.web.dto;

import com.ewok.springbootproject.domain.posts.Posts;
import lombok.Builder;
import lombok.Getter;
import lombok.NoArgsConstructor;

@Getter
public class PostsUpdateRequestDto {

    private String author;
    private String meme;
    private String summary;
    private String description;
    private String reference;
    private String login;

    @Builder
    public PostsUpdateRequestDto(String author, String meme, String summary, String description, String reference, String login) {
        this.author = author;
        this.meme = meme;
        this.summary = summary;
        this.description = description;
        this.reference = reference;
        this.login = login;
    }

    public Posts toEntity() {
        return Posts.builder()
                .author(author)
                .meme(meme)
                .summary(summary)
                .description(description)
                .reference(reference)
                .login(login)
                .build();
    }
}

이 클래스는 사용자가 글 수정을 요청할 때 수정한 정보를 담아 오기 위한 클래스이다.

 

수정 버튼을 클릭하면 에러가 발생했는데 에러 메시지를 보니

기본 생성자가 없다는 것이었다.

 

클래스에 @NoArgsConstructor를 추가하니 문제가 해결되었다.