springboot整合disconf

springboot整合disconf

摘要

springboot整合disconf

demo地址

https://github.com/daodaovps/disconf-demo-springboot

使用非常简单

先引入一个config类

package disconf.config;

import com.baidu.disconf.client.common.annotations.DisconfItem;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;

@Service
@Scope("singleton")
//@DisconfFile(filename = "simple.properties")
public class SimpleConfig3 {

    private String cellno;

    @DisconfItem(key = "cellno")
    public String getCellno() {
        return cellno;
    }

    public void setCellno(String cellno) {
        this.cellno = cellno;
    }
}

再autowired引用

    @Autowired
    private SimpleConfig3 config3;