[DEV] 기록

[SpringBoot] git에 application.properties 안 올리는 방법

꾸준함. 2022. 4. 10. 00:30

개요

구글 SMTP 설정 정보를 실수로 github에 올리니 GitGuardian에서 보안 알림 메일이 엄청 왔습니다.

이런 민감 설정 정보는 github에 올리지 않도록 .gitignore 파일에 설정해야 하는데 비교적 간단하므로 짧게 소개하겠습니다.

 

해결 방법

우선, git에 올리고 싶지 않은 민감 정보들만 별도로 설정하는 properties를 생성해줍니다.

 

이후 Edit Configurations > Active profiles에 security와 함께 원하는 profile 추가

 

* SpringBoot 2.4 버전부터 properties에 active profile이 설정된 상태에서 spring.profiles.include를 통해 profile 추가하는 방법이 막혔습니다.

* https://spring.io/blog/2020/08/14/config-file-processing-in-spring-boot-2-4

 

Config file processing in Spring Boot 2.4

<div class="paragraph"> <p>Spring Boot 2.4.0.M2 has <a href="https://spring.io/admin/blog/4170-spring-boot-2-4-0-m2-is-now-available">just been released</a>, and it brings with it some interesting changes to the way that <code>application.properties</code>

spring.io

 

마지막으로  .gitignore에 해당 properties를 추가해주면 git에 안 올라가는 것을 확인할 수 있습니다.

 

 

반응형