티스토리 뷰

작업자의 작업 환경

- Intellij

- Windows 10

 

HelloResponseDto.java

import lombok.Getter;
import lombok.RequiredArgsConstructor;

@Getter
@RequiredArgsConstructor
public class HelloResponseDto {

    private final String name;
    private final int amount;

}

 

HelloResponseDtoTest.java

import org.junit.Test;

import static org.assertj.core.api.Assertions.assertThat;


public class HelloResponseDtoTest {

    @Test
    public void 롬복_기능_테스트(){

        String name = "test";
        int amount= 1000;

        HelloResponseDto dto = new HelloResponseDto(name, amount);

        assertThat(dto.getName()).isEqualTo(name);
        assertThat(dto.getAmount()).isEqualTo(amount);

    }
}

 

위 코드에서 

 

error: variable name not initialized in the default constructor

error: variable amount not initialized in the default constructor

 

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

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

 

정상적으로 빌드가 됨을 확인 할 수 있다.

댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
글 보관함