Spring

    [Spring] application.yml에서 값 가져오기

    greeting: message: Welcome to the User Service 첫 번째 방법. Env객체 사용하기 @RestController @RequestMapping("/") public class UserController { private Environment env; @Autowired public UserController(Environment env) { this.env = env; } @GetMapping("/welcome") public String welcome(){ return env.getProperty("greeting.message"); } } 두 번째 방법. @Value 사용하기 우선 클래스를 하나 만들어주고, @Component어노테이션을 추가한다. package co..