ConsulPropertySource.java 文件源码

java
阅读 31 收藏 0 点赞 0 评论 0

项目:spring-cloud-consul 作者:
protected Properties generateProperties(String value,
        ConsulConfigProperties.Format format) {
    final Properties props = new Properties();

    if (format == PROPERTIES) {
        try {
            // Must use the ISO-8859-1 encoding because Properties.load(stream)
            // expects it.
            props.load(new ByteArrayInputStream(value.getBytes("ISO-8859-1")));
        }
        catch (IOException e) {
            throw new IllegalArgumentException(value
                    + " can't be encoded using ISO-8859-1");
        }

        return props;
    }
    else if (format == YAML) {
        final YamlPropertiesFactoryBean yaml = new YamlPropertiesFactoryBean();
        yaml.setResources(new ByteArrayResource(value.getBytes()));

        return yaml.getObject();
    }

    return props;
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号