Search in sources :

Example 1 with ReloadingPropertyPlaceholderConfigurer

use of com.baidu.disconf.client.addons.properties.ReloadingPropertyPlaceholderConfigurer in project disconf-spring-boot-starter by xjzrc.

the class DisconfAutoConfiguration method disconfReloadingPropertyPlaceholderConfigurer.

/**
 * 当配置文件改变,会自动reload到系统
 *
 * @param factoryBean 会自动reload配置工厂
 * @return ReloadingPropertyPlaceholderConfigurer
 * @throws IOException IOException
 */
@Bean
@ConditionalOnBean(name = "disconfReloadablePropertiesFactoryBean")
public ReloadingPropertyPlaceholderConfigurer disconfReloadingPropertyPlaceholderConfigurer(@Qualifier("disconfReloadablePropertiesFactoryBean") ReloadablePropertiesFactoryBean factoryBean) throws IOException {
    ReloadingPropertyPlaceholderConfigurer configurer = new ReloadingPropertyPlaceholderConfigurer();
    configurer.setOrder(1);
    configurer.setIgnoreResourceNotFound(true);
    configurer.setIgnoreUnresolvablePlaceholders(true);
    configurer.setProperties(factoryBean.getObject());
    addPropertiesPropertySource("disconfReloadableProperties", factoryBean.getObject());
    return configurer;
}
Also used : ReloadingPropertyPlaceholderConfigurer(com.baidu.disconf.client.addons.properties.ReloadingPropertyPlaceholderConfigurer) ConditionalOnBean(org.springframework.boot.autoconfigure.condition.ConditionalOnBean) ConditionalOnBean(org.springframework.boot.autoconfigure.condition.ConditionalOnBean) DisconfMgrBean(com.baidu.disconf.client.DisconfMgrBean) ReloadablePropertiesFactoryBean(com.baidu.disconf.client.addons.properties.ReloadablePropertiesFactoryBean) Bean(org.springframework.context.annotation.Bean)

Aggregations

DisconfMgrBean (com.baidu.disconf.client.DisconfMgrBean)1 ReloadablePropertiesFactoryBean (com.baidu.disconf.client.addons.properties.ReloadablePropertiesFactoryBean)1 ReloadingPropertyPlaceholderConfigurer (com.baidu.disconf.client.addons.properties.ReloadingPropertyPlaceholderConfigurer)1 ConditionalOnBean (org.springframework.boot.autoconfigure.condition.ConditionalOnBean)1 Bean (org.springframework.context.annotation.Bean)1