Spring Boot 하나의 yml 파일로 개발 및 운영 분리
1. activate 설정
application.yml에 active하려는 환경을 설정한다.
1
2
3
spring:
profiles:
active: local
2. 내용 작성
application.yml에 local, dev, prod를 설정한다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
spring:
profiles:
active: local
---
# local
spring:
config:
activate:
on-profile: local
datasource:
driver-class-name: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
jdbc-url: jdbc:log4jdbc:postgresql://localhost:5432/postgres?charSet=UTF-8
username: postgres
password: postgres
---
# dev
spring:
config:
activate:
on-profile: dev
datasource:
driver-class-name: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
jdbc-url: jdbc:log4jdbc:postgresql://localhost:5432/postgres?charSet=UTF-8
username: postgres
password: postgres
---
# prod
spring:
config:
activate:
on-profile: prod
datasource:
driver-class-name: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
jdbc-url: jdbc:log4jdbc:postgresql://localhost:5432/postgres?charSet=UTF-8
username: postgres
password: postgres
3. 실행 확인
This post is licensed under CC BY 4.0 by the author.