티스토리 뷰
개발/Spring boot
gradle @Test error: variable not initialized in the default constructor
henry.hong 2019. 12. 9. 13:54작업자의 작업 환경
- 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')
정상적으로 빌드가 됨을 확인 할 수 있다.
'개발 > Spring boot' 카테고리의 다른 글
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 알고리즘
- @MapperScan
- tomcat
- 2438
- 백준11021
- 백준2438
- utf8mb4
- Lombok
- 백준2439
- 언어셋
- EC2
- 백준15552
- 11022
- 백준
- Jenkins
- SqlSessionFactory
- 백준4673
- Oracle
- Java
- 백준11022
- gradle
- sqlSessionTemplate
- SpringBoot
- gitlab
- AWS
- ubuntu
- 백준2742
- gitlab삭제
- swap
- intellij
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함