Skip to content

no-args constructor #172

Closed Answered by haileyKimDev
haileyKimDev asked this question in Q&A
Jun 5, 2023 · 3 comments · 5 replies
Discussion options

You must be logged in to vote

@cowtowncoder Thank you for your comment!
I am working on a project using Spring Boot version 2.7.9 and JDK 11.
When I execute the code to create a DTO class as follows, I encounter the following error.

Here is the dto class :

@Getter
@AllArgsConstructor
@Builder
public class CartCreateDto {

  private final Long productId;
  private final int count;

  public Cart toEntity(Long memberId) {
    return Cart.builder()
        .productId(getProductId())
        .memberId(memberId)
        .count(getCount())
        .build();
  }
}

The above class satisfies both conditions: it does not require a no-arguments ("default") constructor and it does not have an @JsonCreator annotated constructor or…

Replies: 3 comments 5 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@mohanaraosv
Comment options

@haileyKimDev
Comment options

Answer selected by haileyKimDev
Comment options

You must be logged in to vote
3 replies
@haileyKimDev
Comment options

@cowtowncoder
Comment options

@haileyKimDev
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants