728x90
반응형
How do you get current active/default Environment profile programmatically in Spring?
I need to code different logic based on different current Environment profile. How can you get the currently active and default profiles from Spring?
stackoverflow.com
https://devfoxstar.github.io/java/spring-profiles-active/
자바 스프링에서 Profile 정보 가져오기 (Spring Profiles Active)
스프링 프로젝트에서 Profile 설정은 기본입니다. local, dev, qa, stg, prod 등 개발 환경에 맞게 지정해 줍니다. 가끔 지정된 Profile…
devfoxstar.github.io
@Service
class ProfileService(
val environment: Environment
) {
fun get(): Profile? {
return Profile[environment.activeProfiles.firstOrNull()]
}
fun isTest(): Boolean {
return get() != Profile.PRD
}
}728x90
반응형
'공부 (@Deprecated)' 카테고리의 다른 글
| [google sheet] 환율 정보 가져오기 (0) | 2023.10.21 |
|---|---|
| [인천국제공항] 외국 여행시 주차대행 서비스 `현대주차` (1) | 2023.10.21 |
| [spring] @SpringBootApplication(scanBasePackages = "com.seunggabi") (0) | 2023.10.17 |
| [sh] lowercase, uppercase (0) | 2023.10.17 |
| [jdk] install 17 (0) | 2023.10.17 |