스프링 부트 설정은 application.yml 파일로 하는데
application.yml 파일을 환경별로 두면 중복되는 부분이 발생하거나
환경별로 따로 참조해야 하는 경우가 발생합니다.



위의 application.yml 파일들을 보면
환경별 DB 접속 정보와 로그 파일 위치가 다르지만
암호화를 담당하는 Jasypt 빈은 중복되는 것을 알 수 있습니다.


encyrpt.yml을 생성하여 중복되는 Jasypt 빈을 따로 관리합니다.



각 환경별 application.yml에서 spring.config.import 속성을 사용하여
encrypt.yml 파일을 참조하면 중복되는 Jasypt 빈을 스프링 환경에 적용할 수 있습니다.
spring.config.import 속성은 외부에 있는 파일 정보를 참조하는 역할을 합니다.

참조할 파일이 2개 이상인 경우
위와 같이 "- 파일명"으로 해서 참조하면 됩니다.
application.yml 파일 내에 중복되는 부분을 외부에 따로 파일을 만들어 참조하거나
환경별로 따로 참조해야 하는 경우가 있으면
spring.config.import를 통해서 해결하면 유용할 것 같습니다.
'dev > 스프링' 카테고리의 다른 글
Spring Boot Redis Publisher (0) | 2024.02.05 |
---|---|
Spring Boot Session Store Type Redis (0) | 2024.01.25 |
Spring Boot Session Store Type JDBC (0) | 2023.11.27 |
Spring Boot OAuth2 로그인 (0) | 2023.11.14 |
Spring WebSocketSession (0) | 2023.08.22 |