1.自定义Yaml工厂
package com.x.globalcommonservice.global.spring.configuration;
import org.springframework.core.env.PropertySource;
import org.springframework.core.io.support.EncodedResource;
import org.springframework.core.io.support.PropertySourceFactory;
import org.yaml.snakeyaml.Yaml;
import java.io.IOException;
import java.io.InputStream;
import java.util.Map;
public class YamlPropertySourceFactory implements PropertySourceFactory {
@Override
public PropertySource<?> createPropertySource(String name, EncodedResource resource) throws IOException {
try (InputStream inputStream = resource.getInputStream()) {
Map<String, Object> source = new Yaml().load(inputStream);
return new org.springframework