twocowsong

@Value 어노테이션 본문

IT/SpringBoot

@Value 어노테이션

WsCode 2022. 1. 18. 21:06

@Value어노테이션은 스프링빈에 등록된 객체에 기본값을 부여할수있다.

@Component
public class Car{
	@Value("10")
	public int speed;
}

위처럼 Car Class @Value에 10으로 주면 기본값이 10으로 출력된다.

@Component
public class Car{
	@Value("${test.value}")
	public int speed;
}
application.properties
test.value=100

@Value에 ${properties값}으로 설정하여 사용도가능하다.

'IT > SpringBoot' 카테고리의 다른 글

@RestController @Controller  (0) 2022.01.24
@Scheduled  (0) 2022.01.23
Redirect, forward, RedirectAttributes  (0) 2022.01.23
@ModelAttribute, @PathVariable, @RequestBody  (0) 2022.01.18
@Data  (0) 2022.01.18