본문 바로가기
에러 디버그 기록

Mastruct, lombok 관련 에러

by jphwany 2022. 10. 11.

java: constructor EnrollResponseDto in class com.cactusvilleage.server.challenge.web.dto.response.EnrollResponseDto cannot be applied to given types; required: com.cactusvilleage.server.challenge.entities.Challenge.ChallengeType,boolean,int found: no arguments reason: actual and formal argument lists differ in length

build.gradle 디펜던시 순서를 지켜야한다 

annotationProcessor 선언 할 때 타겟 클래스에 빌더가 정의되어 있다면 빌더가,
생성자가 정의되어 있다면, 생성자가 사용된다

그런데 동시에 선언되어 있을 경우,
빌더가 우선순위가 높다

그래서 빌더를 활용할 생각이라면 mapstruct-processor가 lombok 관련 보다 상단에 위치해야 한다.
만약 lombok 보다 하단에 위치하는 경우, 생성자만 활용이 된다.

생성자를 활용할거라면 AllArgsConstructor를 지정해서 모든 속성을 포함하는 생성자를 만들어야 하며 NoArgsConstructor로 기본 생성자만 만들거라면 Setter 메소드를 포함시켜야 한다.

댓글