본문 바로가기

서버

Spring boot - 배포시 운영에서만 사용하는 yml 적용하기

728x90

개발 외 배포시에만 사용하는 yml을 

github 레포에 올리면 안되기 때문에 

 

운영서버에 따로 파일을 생성하여

서버시작시에 적용한다.

 


1. 운영서버에 application-prod.yml 생성

 

vi ~/directory/application-prod.yml

 

[application-prod.yml]

spring:
  datasource:
    url: jdbc:mariadb://운영디비서버:3306/test
    username: 운영계정
    password: 운영비번
    driver-class-name: org.mariadb.jdbc.Driver

mybatis:
  mapper-locations: classpath:mapper/*.xml
  configuration:
    map-underscore-to-camel-case: true
    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl

 

 

2. gradle 빌드하기

 

gradle clean
gradle build -x test

 

 

3. 서버 시작하기

nohup java -jar -Dspring.config.location=/directory/application-prod.yml 어플리케이션명.jar 2>&1 &