spring boot使用disconf进行配置管理

1、disconf.properties

disconf.enable.remote.conf=true
disconf.conf_server_host=disconf.xxx.com
disconf.version=1_0_0_0
disconf.app=app1
disconf.env=rd
disconf.ignore=
disconf.conf_server_url_retry_times=1
disconf.conf_server_url_retry_sleep_seconds=1
disconf.user_define_download_dir=./config

2、disconf.xml





    

    
    
        
        
    
    
    

    
    
        
            
                classpath*:app.properties
            
        
    

    
        
        
        
            
                
            
        
    

3、Application启动文件

@SpringBootApplication
@ImportResource({ "classpath:disconf.xml" })
@EnableConfigurationProperties
public class Application
{
    public static void main(String[] args) throws Exception
    {
        SpringApplication.run(Application.class, args);
    }
}

4、AppConfig文件

package com.vipabc.cpimsapi.config;

import com.baidu.disconf.client.common.annotations.DisconfFile;
import com.baidu.disconf.client.common.annotations.DisconfFileItem;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

@Configuration
@DisconfFile(filename = "app.properties")
public class AppConfig {
    /**
     * 请求外部链接超时时间
     */
    private Integer urlConnectionTimeout;

    @DisconfFileItem(name = "app.url_connection_timeout", associateField = "urlConnectionTimeout")
    public Integer getUrlConnectionTimeout() {
        return urlConnectionTimeout;
    }

    public void setUrlConnectionTimeout(Integer urlConnectionTimeout) {
        this.urlConnectionTimeout = urlConnectionTimeout;
    }
}

5、app.properties

app.url_connection_timeout=5000

你可能感兴趣的:(spring boot使用disconf进行配置管理)