lombok에서 getter, setter, tostring의 역할을 대신하여 코드의 길이를 줄여준다.
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
@Getter
@Setter
@ToString
public class Person {
private String name;
private int age;
private String address;
}
@Getter
Class 내 모든 필드의 Getter method를 자동 생성
@Setter
Class 내 모든 필드의 Setter method를 자동 생성
@ToString
Class 내 모든 필드의 toString method를 자동 생성
https://standout.tistory.com/138
초기화와접근, setter getter
setter getter set은 설정하는것, get은 접근할수 있도록 하는것. set+변수명: 값 초기화(설정) get+변수명: 접근하지 못하는 변수에 접근할수있도록 허용 = public private int num; public int getNum() { // Getter retur
standout.tistory.com
https://standout.tistory.com/471
Gradle lombok추가, build.gradle
implementation 'org.projectlombok:lombok'//lombok추가
standout.tistory.com
'JAVA > Spring' 카테고리의 다른 글
Annotation - @AllArgsConstructor (0) | 2023.04.20 |
---|---|
Annotation - @EqualsAndHashCode (0) | 2023.04.20 |
Annotation - @mapper @Select @Insert @Update @Delete (0) | 2023.04.20 |
Annotation - @SpringBootConfiguration (0) | 2023.04.20 |
Annotation - @EnableAutoConfiguration (0) | 2023.04.20 |