문서의 선택한 두 판 사이의 차이를 보여줍니다.
| 양쪽 이전 판 이전 판 다음 판 | 이전 판 | ||
|
springframework:springboot:properties [2021/01/11 22:05] kwon37xi [profile include] |
springframework:springboot:properties [2024/06/12 09:00] (현재) kwon37xi |
||
|---|---|---|---|
| 줄 1: | 줄 1: | ||
| ====== SpringBoot Properties ====== | ====== SpringBoot Properties ====== | ||
| * [[springframework: | * [[springframework: | ||
| + | * [[java: | ||
| + | * [[springframework: | ||
| * 보통 '' | * 보통 '' | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | |||
| + | ===== 기본값 설정 ===== | ||
| + | * 이미 지정된 property 이면, 해당 값을 사용하고, | ||
| + | * '' | ||
| + | <code yml> | ||
| + | testing: | ||
| + | my: | ||
| + | username: ${external.username: | ||
| + | password: ${external.password: | ||
| + | </ | ||
| + | * [[https:// | ||
| + | |||
| + | <code yml> | ||
| + | testing: | ||
| + | my: | ||
| + | username: ${external.username: | ||
| + | password: ${external.password:# | ||
| + | </ | ||
| + | <code java> | ||
| + | @Value(" | ||
| + | private String username; | ||
| + | |||
| + | @Value(" | ||
| + | private String password; | ||
| + | </ | ||
| ===== profile 별 설정 ===== | ===== profile 별 설정 ===== | ||
| 줄 93: | 줄 124: | ||
| * [[https:// | * [[https:// | ||
| * 이 경우 '' | * 이 경우 '' | ||
| + | |||
| + | ===== YAML을 '' | ||
| + | * [[https:// | ||
| + | * [[https:// | ||
| + | |||
| + | <code java> | ||
| + | @PropertySource( | ||
| + | value = " | ||
| + | factory = YamlPropertySourceFactory.class | ||
| + | ) | ||
| + | </ | ||
| + | |||
| + | <code java> | ||
| + | public class YamlPropertySourceFactory implements PropertySourceFactory { | ||
| + | |||
| + | @Override | ||
| + | public PropertySource<?> | ||
| + | throws IOException { | ||
| + | YamlPropertiesFactoryBean factory = new YamlPropertiesFactoryBean(); | ||
| + | factory.setResources(encodedResource.getResource()); | ||
| + | |||
| + | Properties properties = factory.getObject(); | ||
| + | |||
| + | return new PropertiesPropertySource(encodedResource.getResource().getFilename(), | ||
| + | } | ||
| + | } | ||
| + | |||
| + | </ | ||
| ===== @ConfigurationProperties ===== | ===== @ConfigurationProperties ===== | ||
| * '' | * '' | ||
| 줄 126: | 줄 185: | ||
| ===== 모든 properties 로그로 남기기 ===== | ===== 모든 properties 로그로 남기기 ===== | ||
| * [[https:// | * [[https:// | ||
| - | * 아래와 같이 '' | + | * 최종적으로 결정된 properties 목록을 확인하고자 할 때, 아래와 같이 '' |
| <code java> | <code java> | ||
| @Component | @Component | ||
| 줄 173: | 줄 232: | ||
| com.baeldung.environmentpostprocessor.PriceCalculationEnvironmentPostProcessor | com.baeldung.environmentpostprocessor.PriceCalculationEnvironmentPostProcessor | ||
| </ | </ | ||
| + | |||
| + | ===== YAML Duration ===== | ||
| + | * Spring Boot 2.1 부터 [[https:// | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| ===== 참고 ===== | ===== 참고 ===== | ||