类org.springframework.boot.env.RandomValuePropertySource源码实例Demo

下面列出了怎么用org.springframework.boot.env.RandomValuePropertySource的API类实例代码及写法,或者点击链接到github查看源代码。

public static List<SpringConfigurationPropertySource> fromConfigurableEnvironment(ConfigurableEnvironment configurableEnvironment, boolean ignoreUnknown) {
    List<ConfigurationPropertySource> sources = Bds.listOf(ConfigurationPropertySources.get(configurableEnvironment));
    return Bds.of(sources).map(it -> {
        if (IterableConfigurationPropertySource.class.isAssignableFrom(it.getClass())) {
            return getPropertySource(configurableEnvironment, ignoreUnknown, it);
        } else if (RandomValuePropertySource.class.isAssignableFrom(it.getUnderlyingSource().getClass())) {
            //We know an underlying random source can't be iterated but we don't care. It can't give a list of known keys.
            return null;
        } else {
            if (ignoreUnknown) {
                return null;
            } else {
                throw new RuntimeException(
                    new UnknownSpringConfigurationException("Unknown spring configuration type. We may be unable to find property information from it correctly. Likely a new configuration property source should be tested against. "));
            }
        }
    }).filterNotNull().toList();

}
 
@PostConstruct
public void initialize() {
	MutablePropertySources propertySources = environment.getPropertySources();
	PropertySource propertySource = propertySources
			.get(RandomValuePropertySource.RANDOM_PROPERTY_SOURCE_NAME);
	if (propertySource != null) {
		propertySources.addLast(new CachedRandomPropertySource(propertySource));
	}
}
 
 类所在包
 类方法
 同包方法