kok202
java -jar 로 application.yml 오버라이딩

2019. 7. 4. 13:23[개발] 기록/정리되지 않은 개념

application.yml

playground:
  myValue: 32
  myBool: false

TestController.java

@RestController
@RequestMapping
public class TestController {
    @Value("${playground.myValue}")
    private int propertyTest;
    @Value("${playground.myBool}")
    private boolean propertyBool;

    @GetMapping("/")
    public void indexHandler(){
        System.out.println("@@@@ propertyTest : " + propertyTest);
        System.out.println("@@@@ propertyBool : " + propertyBool);
    }
}

 

 

 

 

 

실행 커맨드 1

java -jar spring-playground-0.0.1-SNAPSHOT.jar

결과

@@@@ propertyTest : 32
@@@@ propertyBool : false

 

 

 

 

 

실행 커맨드 2 

java -jar spring-playground-0.0.1-SNAPSHOT.jar --playground.test=20 --playground.bool=true

결과

@@@@ propertyTest : 20
@@@@ propertyBool : true