类org.springframework.boot.convert.ApplicationConversionService源码实例Demo

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

public static JasyptEncryptorConfigurationProperties bindConfigProps(ConfigurableEnvironment environment) {
    final BindHandler handler = new IgnoreErrorsBindHandler(BindHandler.DEFAULT);
    final MutablePropertySources propertySources = environment.getPropertySources();
    final Binder binder = new Binder(ConfigurationPropertySources.from(propertySources),
            new PropertySourcesPlaceholdersResolver(propertySources),
            ApplicationConversionService.getSharedInstance());
    final JasyptEncryptorConfigurationProperties config = new JasyptEncryptorConfigurationProperties();

    final ResolvableType type = ResolvableType.forClass(JasyptEncryptorConfigurationProperties.class);
    final Annotation annotation = AnnotationUtils.findAnnotation(JasyptEncryptorConfigurationProperties.class,
            ConfigurationProperties.class);
    final Annotation[] annotations = new Annotation[]{annotation};
    final Bindable<?> target = Bindable.of(type).withExistingValue(config).withAnnotations(annotations);

    binder.bind("jasypt.encryptor", target, handler);
    return config;
}
 
static <T> T bindConfig(HashMap<String, Object> properties,
		AbstractRoutePredicateFactory<T> factory) {
	ApplicationConversionService conversionService = new ApplicationConversionService();
	conversionService.addConverter(new StringToZonedDateTimeConverter());
	// @formatter:off
	T config = new ConfigurationService(null, () -> conversionService, () -> null)
			.with(factory)
			.name("myname")
			.normalizedProperties(properties)
			.bind();
	// @formatter:on
	return config;
}
 
源代码3 项目: springdoc-openapi   文件: WebMvcConfiguration.java
@Override
public void addFormatters(FormatterRegistry registry) {
	ApplicationConversionService.configure(registry);
}
 
 类所在包
 同包方法