다음과 같이 @Getter를 사용했음에도 불구하고 Getter 메서드에서 에러가 발생
package com.example.simplespringboottest.board;
import lombok.Getter;
@Getter
public class BoardDto {
private Long id;
private String title;
private String content;
public BoardDto(Board board){
this.id = board.getId();
this.title = board.getTitle();
this.content = board.getContent();
}
}
D:\BigData\Spring\Spring Security\simple-springboot-test\src\main\java\com\example\simplespringboottest\board\Board.java:21: error: cannot find symbol
this.id = dto.getId();
^
symbol: method getId()
location: variable dto of type BoardDto
D:\BigData\Spring\Spring Security\simple-springboot-test\src\main\java\com\example\simplespringboottest\board\Board.java:22: error: cannot find symbol
this.title = dto.getTitle();
^
symbol: method getTitle()
location: variable dto of type BoardDto
D:\BigData\Spring\Spring Security\simple-springboot-test\src\main\java\com\example\simplespringboottest\board\Board.java:23: error: cannot find symbol
this.content = dto.getContent();
^
symbol: method getContent()
location: variable dto of type BoardDto
한 번도 이런 에러는 겪어보지 않아서 ChatGPT에게 물어보니 아래 두 개를 의존성 추가하라고 하였음
dependencies {
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
}
해결 완료
실제로는 annotationProcessor 하나만 추가해도 정상 작동이 되었음
한 번도 이런 적이 없었는데, 구글링을 해보아도 @Getter사용 시에도 Getter 메서드가 오류가 발생할 경우 아래 의존성을 추가하라는 것 뿐 실질적인 원인은 찾지 못함
annotationProcessor 'org.projectlombok:lombok'
'Various Error' 카테고리의 다른 글
[Eureka] Eureka Client의 UnsatisfiedDependencyException 에러 (0) | 2024.08.20 |
---|---|
[JSON] HttpMediaTypeNotAcceptableException (0) | 2024.08.19 |
[JSON] InvalidDefinitionException (0) | 2024.08.19 |
[Spring Data JPA] PropertyReferenceException 에러 (0) | 2024.08.16 |
[IntellJ] application.yml 사용 시 데이터베이스 연동 주의 사항 (0) | 2024.08.04 |