
- 기존 → 어떤 프로파일을 사용할지 설정하는 파일로 사용
application.properties
spring.profiles.active=dev
- dev → 개발 환경 설정
- 개발 환경에서 필요한 세팅
logging.level.shop.mtcoding.blog=DEBUG
→ 앱에서 로그 레벨을 디버깅 수준으로 만든다logging.level.org.hibernate.type=TRACE
→ db에서 로그 레벨을 트레이스 수준으로 만든다
application-dev.properties
server.port=8080
# vscode console highlight
spring.output.ansi.enabled=always
# utf-8
server.servlet.encoding.charset=utf-8
server.servlet.encoding.force=true
# DB
spring.datasource.driver-class-name=org.h2.Driver
spring.datasource.url=jdbc:h2:mem:test
spring.datasource.username=sa
spring.datasource.password=
spring.h2.console.enabled=true
# JPA table create or none
spring.jpa.hibernate.ddl-auto=create
# query log
spring.jpa.show-sql=true
# dummy data
spring.sql.init.data-locations=classpath:db/data.sql
# create dummy data after ddl-auto create
spring.jpa.defer-datasource-initialization=true
# mustache request expose
###spring.mustache.servlet.expose-request-attributes=true
###spring.mustache.servlet.expose-session-attributes=true
# sql formatter
spring.jpa.properties.hibernate.format_sql=true
# log
logging.level.shop.mtcoding.blog=DEBUG
logging.level.org.hibernate.type=TRACE
- local → 로컬에서 테스트 환경 설정
- 실제 서비스와 비슷한 환경에서 확인하기 위해 필요한 세팅
- 기밀 정보는 운영체제의 환경 변수를 사용한다 →
${RDS_USERNAME}
실제 환경을 맞출 수 없음. 개발(윈도우) 실제(윈도우)
application-local.properties
server.port=5000
# utf-8
server.servlet.encoding.charset=utf-8
server.servlet.encoding.force=true
# DB
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://localhost:3306/blogdb
spring.datasource.username=root
spring.datasource.password=bitc5600!
# JPA table create or none
spring.jpa.hibernate.ddl-auto=none
# log (trace -> debug -> info -> warn -> error)
## INFO 로 설정하면 하위의 warn, error 도 표기 된다
logging.level.shop.mtcoding.blog=INFO
## db에서 생기는 모든 내용은 자세하게 내용을 남기기 위해 trace 사용
logging.level.org.hibernate.type=TRACE
- prod → 실제 서비스 환경 설정
- 실제 서버에서 설정된 값을 사용한다 →
${RDS_USERNAME}
리눅스 용
application-prod.properties
server.port=5000
# utf-8
server.servlet.encoding.charset=utf-8
server.servlet.encoding.force=true
# DB
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://${RDS_HOST}:3306/blogdb
spring.datasource.username=${RDS_USERNAME}
spring.datasource.password=${RDS_PASSWORD}
# JPA table create or none
spring.jpa.hibernate.ddl-auto=none
# log (trace -> debug -> info -> warn -> error)
## INFO 로 설정하면 하위의 warn, error 도 표기 된다
logging.level.shop.mtcoding.blog=INFO
## db에서 생기는 모든 내용은 자세하게 내용을 남기기 위해 trace 사용
logging.level.org.hibernate.type=TRACE
각각의 사용법
- dev -> 개발(h2) -> build (test하고, .jar 생성) -> .jar는 어느 환경에서 만들던 똑같다
- local -> 로컬 환경에서 테스트 해본다
- prod → 실제 서버 환경에서 실행한다
.jar 파일을 프로파일 세팅에 따라 다르게 실행하는 방법
java -jar blog-1.0.jar --spring.profiles.active=local

Share article