develog

[spring] 앱에 파라미터 전달하기 본문

카테고리 없음

[spring] 앱에 파라미터 전달하기

냐옴 2025. 9. 25. 22:31

 

* OS Environment Variable
- OS 레벨
- export db_user=test
- System.getenv("key")

* VM Options
- JVM 레벨
- java -Ddb_user=test -jar app.jar
- System.getProperty("key")

* Program arguments
- APP 레벨
- java -jar app.jar --db_user=test
- @Value("${key}")

 

1. Program arguments (--key=value)
2. VM Options (-Dkey=value)
3. OS Environment Variables (KEY=value)
4. application.properties / application.yml
우선순위는 1 > 2 > 3 > 4

Comments