java/SpringBoot

Lombok 사용하기

Dev갱이 2022. 8. 5. 05:09
728x90
스프링부트에서 vo객체를 통해서 getter setter를 생성 하여 작업 하는데, getter와 setter를 생성 안해도 된다? getter와 setter를 어노테이션으로 처리하나보다

 

spring.io에서 디펜던시를 가져와서 추가해준다
//build.gradle
dependencies {
	implementation 'org.springframework.boot:spring-boot-starter-web'
	providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
	testImplementation 'org.springframework.boot:spring-boot-starter-test'

	// https://mvnrepository.com/artifact/org.apache.tomcat.embed/tomcat-embed-jasper
	implementation 'org.apache.tomcat.embed:tomcat-embed-jasper'
	developmentOnly 'org.springframework.boot:spring-boot-devtools'
	implementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter:2.2.2'
	runtimeOnly 'org.mariadb.jdbc:mariadb-java-client'
	implementation 'javax.servlet:jstl'
	
	compileOnly 'org.projectlombok:lombok'
	annotationProcessor 'org.projectlombok:lombok'
}
import lombok.Data;

@Data


//이거 한줄이면 getter, setter, 생성자 함수가 한번에 해결된다!

 

728x90