공부/project(01)
Spring Boot 프로젝트 profile ( local, dev, prod )설정
성난호랑이 시니철
2024. 4. 22. 16:15
Spring Boot 프로젝트 profile ( local, dev, prod )설정
프로젝트 시작시 로컬/개발/상용 DB 서버가 다르거나 정보가 다를때 profile 을 나눠서 작합니다.
이때 profile 을 나눠서 작업하면 좋습니다.
Gradle 설정 추가
ext.profile = (!project.hasProperty('profile') || !profile) ? 'local' : profile
sourceSets {
main {
resources {
srcDir "src/main/resources-${profile}"
}
}
}
로컬로 사용한다는 내용입니다.
저대로 프로젝트를 실행하면 로컬 resoures 가 실행됩니다.
이미지와 같이 resources를 구분합니다.
저는 공통 resources 에서 DB정보만 분리 하였습니다.
이대로면 끝입니다.