org.springframework.boot.context.properties.bind.PropertySourcesPlaceholdersResolver#org.springframework.boot.context.properties.bind.handler.IgnoreErrorsBindHandler源码实例Demo

下面列出了org.springframework.boot.context.properties.bind.PropertySourcesPlaceholdersResolver#org.springframework.boot.context.properties.bind.handler.IgnoreErrorsBindHandler 实例代码,或者点击链接到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;
}