문서의 선택한 두 판 사이의 차이를 보여줍니다.
양쪽 이전 판 이전 판 다음 판 | 이전 판 다음 판 양쪽 다음 판 | ||
springframework:springboot:properties [2021/01/15 15:05] kwon37xi [YAML을 ''@PropertySource''로 사용하기] |
springframework:springboot:properties [2021/02/20 23:02] kwon37xi |
||
---|---|---|---|
줄 2: | 줄 2: | ||
* [[springframework: | * [[springframework: | ||
* 보통 '' | * 보통 '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
+ | * '' | ||
===== profile 별 설정 ===== | ===== profile 별 설정 ===== | ||
줄 98: | 줄 102: | ||
* [[https:// | * [[https:// | ||
- | < | + | < |
@PropertySource( | @PropertySource( | ||
value = " | value = " | ||
factory = YamlPropertySourceFactory.class | 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 ===== |