Spring Boot

Spring Boot 외부 설정법

iksadnorth 2023. 7. 28. 22:45

👣 개요

Spring Boot에서 설정값을 부여하는 방법은 하드 코딩 외에도 여러 가지를 지원한다.

  1. application.properties 파일
  2. application.yml 파일
  3. 환경 변수
  4. 커맨드 라인 Argments

 

👣 프로퍼티 우선 순위

  1. 유저 홈 디렉토리에 있는 spring-boot-dev-tools.properties
  2. 테스트에 있는 @TestPropertySource
  3. @SpringBootTest 의 properties 속성
  4. 커맨드 라인 Argments
  5. SPRING_APPLICATION_JSON (환경 변수 또는 시스템 프로티) 에 들어있는 프로퍼티
  6. ServletConfig 파라미터
  7. ServletContext 파라미터
  8. java:comp/env JNDI 애트리뷰트
  9. System.getProperties() 자바 시스템 프로퍼티
  10. OS 환경 변수
  11. RandomValuePropertySource
  12. JAR 밖에 있는 특정 프로파일용 application properties
  13. JAR 안에 있는 특정 프로파일용 application properties
  14. JAR 밖에 있는 application properties
  15. JAR 안에 있는 application properties
  16. @PropertySource
  17. 기본 프로퍼티 (SpringApplication.setDefaultProperties)

'Spring Boot' 카테고리의 다른 글

Spring Boot Bean 등록 방법 5가지  (0) 2023.07.29
Spring Logging System  (0) 2023.07.29
Spring Boot HTTP2 적용  (0) 2023.07.28
Spring Boot HTTPS 적용  (0) 2023.07.28
Executable Jar  (0) 2023.07.28