zoukankan      html  css  js  c++  java
  • disconf

    disconf.xml

    1、xml配置

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
    
        <!-- 使用disconf必须添加以下配置 -->
        <bean id="disconfMgrBean" class="com.baidu.disconf.client.DisconfMgrBean" destroy-method="destroy">
            <property name="scanPackage" value="com.dds.rss.route" />
        </bean>
        <bean id="disconfMgrBean2" class="com.baidu.disconf.client.DisconfMgrBeanSecond" init-method="init" destroy-method="destroy">
        </bean>
    
        <!-- 使用托管方式的disconf配置(无代码侵入, 配置更改会自动reload) -->
        <bean id="configproperties_disconf"
              class="com.baidu.disconf.client.addons.properties.ReloadablePropertiesFactoryBean">
            <property name="locations">
                <list>
                    <!--多个动态配置配置在这里-->
                    <value>classpath:version.properties</value>
                </list>
            </property>
        </bean>
    
        <bean id="propertyConfigurer"
              class="com.baidu.disconf.client.addons.properties.ReloadingPropertyPlaceholderConfigurer">
            <property name="ignoreResourceNotFound" value="true" />
            <property name="ignoreUnresolvablePlaceholders" value="true" />
            <property name="propertiesArray">
                <list>
                    <ref bean="configproperties_disconf" />
                </list>
            </property>
        </bean>
    
    </beans>

    2、应用属性配置

    
    /**
     * 描述: ID 属性
     *
     * @author 01374806
     * @date 2018/10/2
     */
    @DisconfFile(filename = "id.properties")
    @Component
    public class IdProperties {
    
        private Long datacenterId = 0L;
    
        @DisconfFileItem(name = "dds.rss.route.id.datacenterId", associateField = "datacenterId")
        public Long getDatacenterId() {
            return datacenterId;
        }
    
        public void setDatacenterId(Long datacenterId) {
            this.datacenterId = datacenterId;
        }
    }

    3、回调(消息通知配置)

    @Slf4j
    @Component
    @DisconfUpdateService(confFileKeys = { "dispatch.properties" })
    public class DispatchPropertiesCallback implements IDisconfUpdate {
    
        @Override
        public void reload() throws Exception {
            log.info("dispatch.properties 检测到更新");
        }
    
    }
  • 相关阅读:
    ScreenToGif 使用教程
    无问西东
    php如何解决中文乱码问题?
    layer父页面调用子页面的方法
    弹层组件文档
    关于svn获取获取文件时 Unable to connect to a repository at URL"https://..."执行上下文错误:参数错误
    centos下修改文件后如何保存退出
    Linux CentOS 7的图形界面安装(GNOME、KDE等)
    CentOS7安装详解
    Could not attach to pid : "xx"最近启动Xcode运行项目都会出现这个问题,再次启动或者多启动几次,就可以正常运行工程了。
  • 原文地址:https://www.cnblogs.com/gendway/p/10696074.html
Copyright © 2011-2022 走看看