문서의 선택한 두 판 사이의 차이를 보여줍니다.
| 양쪽 이전 판 이전 판 다음 판 | 이전 판 | ||
|
springframework:springboot:properties [2021/01/15 15:01] kwon37xi [YAML을 Property 객체로 변환하기] |
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 별 설정 ===== | ||
| 줄 98: | 줄 129: | ||
| * [[https:// | * [[https:// | ||
| - | < | + | < |
| - | @PropertySource(value = " | + | @PropertySource( |
| + | | ||
| + | | ||
| + | ) | ||
| + | </ | ||
| + | |||
| + | <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 ===== | ||
| 줄 181: | 줄 232: | ||
| com.baeldung.environmentpostprocessor.PriceCalculationEnvironmentPostProcessor | com.baeldung.environmentpostprocessor.PriceCalculationEnvironmentPostProcessor | ||
| </ | </ | ||
| + | |||
| + | ===== YAML Duration ===== | ||
| + | * Spring Boot 2.1 부터 [[https:// | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| ===== 참고 ===== | ===== 참고 ===== | ||