org.springframework.boot.config
Class YamlPropertiesFactoryBean
java.lang.Object
org.springframework.boot.config.YamlProcessor
org.springframework.boot.config.YamlPropertiesFactoryBean
- All Implemented Interfaces:
- org.springframework.beans.factory.FactoryBean<Properties>
public class YamlPropertiesFactoryBean
- extends YamlProcessor
- implements org.springframework.beans.factory.FactoryBean<Properties>
Factory for Java Properties that reads from a YAML source. YAML is a nice
human-readable format for configuration, and it has some useful hierarchical
properties. It's more or less a superset of JSON, so it has a lot of similar features.
The Properties created by this factory have nested paths for hierarchical objects, so
for instance this YAML
environments:
dev:
url: http://dev.bar.com
name: Developer Setup
prod:
url: http://foo.bar.com
name: My Cool App
is transformed into these Properties:
environments.dev.url=http://dev.bar.com
environments.dev.name=Developer Setup
environments.prod.url=http://foo.bar.com
environments.prod.name=My Cool App
Lists are represented as comma-separated values (useful for simple String values) and
also as property keys with [] dereferencers, for example this YAML:
servers:
- dev.bar.com
- foo.bar.com
becomes java Properties like this:
servers=dev.bar.com,foo.bar.com
servers[0]=dev.bar.com
servers[1]=foo.bar.com
- Author:
- Dave Syer
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
YamlPropertiesFactoryBean
public YamlPropertiesFactoryBean()
getObject
public Properties getObject()
- Specified by:
getObject in interface org.springframework.beans.factory.FactoryBean<Properties>
getObjectType
public Class<?> getObjectType()
- Specified by:
getObjectType in interface org.springframework.beans.factory.FactoryBean<Properties>
setSingleton
public void setSingleton(boolean singleton)
- Set if a singleton should be created, or a new object on each request otherwise.
Default is
true (a singleton).
isSingleton
public boolean isSingleton()
- Specified by:
isSingleton in interface org.springframework.beans.factory.FactoryBean<Properties>
Copyright © 2013. All Rights Reserved.