Thief of Wealth

variable name not initialized in the default constructor

 

SpringBoot를 책보며 공부중인데 변수 초기화 에러가 뜬다.

 

@Getter // 선언된 모든 필드의 get 메소드를 생성해준다.
@RequiredArgsConstructor // 선언된 모든 final 필드가 포함된 생성자를 생성해준다. (final 안붙어있으면 포함x)
public class HelloResponseDto {
    private final String name;
    private final int amount;
}

 

위와 같이하면 final 변수들은 생성자에 추가해서 그런 오류가 생기지 않을텐데? 

라고 멘붕하고 있었는데, 다행이 잘 정리 해주신 고수님 덕분에 에러를 해결할 수 있었다.

 

https://tube-life.tistory.com/14

 

gradle @Test error: variable not initialized in the default constructor

작업자의 작업 환경 - Intellij - Windows 10 HelloResponseDto.java import lombok.Getter; import lombok.RequiredArgsConstructor; @Getter @RequiredArgsConstructor public class HelloResponseDto { private..

tube-life.tistory.com

 

오류가 발생할 경우. build.gradle 파일에 대해 아래와 같이 추가한다.

//기존
compile('org.projectlombok:lombok')
//추가
testCompile "org.projectlombok:lombok"
annotationProcessor('org.projectlombok:lombok')
testAnnotationProcessor('org.projectlombok:lombok')
profile on loading

Loading...