Giter Site home page Giter Site logo

smconf's Introduction

Smconf专注于分布式环境下配置的统一管理

目前只支持java,其他语言如果需要支持可以使用Smconf提供的Rest API

架构图

目标

  • 提供配置的统一管理
  • 多个环境(生产环境:prod, 线上测试环境:online, 线下测试环境:test, 开发环境:dev)
  • web后台配置管理
  • 配置修改后实时同步到使用的客户端
  • 无缝集成spring和spring boot项目
  • web后台支持不同账号管理不同环境的配置
  • 支持水平扩容,负载,部署多个server,client自动发现

文档

案列

配置管理

配置列表

配置修改

配置历史记录

作者

历史版本下载

FAQ

整合dubbox 2.8.4报错?

Caused by: java.lang.NoSuchMethodError: org.apache.curator.utils.PathUtils.validatePath(Ljava/lang/String;)Ljava/lang/String;

这个错主要是由于dubbo也带了zk的客户端,jar包冲突导致的,所以我们将dubbo旧的版本排除掉

<dependency>
	<groupId>com.alibaba</groupId>
	<artifactId>dubbo</artifactId>
	<exclusions>
		<exclusion>
			<groupId>org.apache.curator</groupId>
			<artifactId>curator-client</artifactId>
		</exclusion>
		<exclusion>
			<groupId>org.apache.curator</groupId>
			<artifactId>curator-framework</artifactId>
		</exclusion>
	</exclusions>
</dependency>

spring boot整合dubbox 2.8.4启动时需要dubbo配置信息怎么办?

由于Smconf的初始化机制是在spring bean实例化之后再对配置bean进行数据加载

spring boot中使用dubbo是用的@bean注解的初始化方式

所以在初始化dubbo的时候,这个时候Smconf的配置还没有初始化好,导致dubbo的配置不能被管理

为了解决这个问题,可以在启动spring前先将配置信息初始化z到环境变量中,这样后面dubbo就可以顺利的初始化了

只需要一行代码即可

public static void main(String[] args) {
	//启动时需要配置来做连接,需要在spring启动前将一些配置信息加载到环境变量使用
	//com.fangjia.ld.service.config是你的配置所在的包
	SmconfInit.init("com.fangjia.ld.service.config");
	
	new SpringApplicationBuilder().sources(LdApplication.class).web(false).run(args);
        try {
        	new CountDownLatch(1).await();
	} catch (InterruptedException e) {
		LOGGER.error("项目启动异常", e);
	}
}

application.properties文件中使用$符号取值

spring.dubbo.application.name=${spring.dubbo.applicationName}
spring.dubbo.registry.address=${spring.dubbo.registryAddress}
spring.dubbo.protocol.name=${spring.dubbo.protocolName}
spring.dubbo.protocol.port=${spring.dubbo.protocolPort}

/**
 * dubbo配置信息
 * @author yinjihuan
 *
 */
@CxytianDiConf(system=Constant.SYSTEM,env=true, prefix="spring.dubbo")
public class DubboConf {
	
	@ConfField("zookeeper地址")
	private String registryAddress = "zookeeper://192.168.10.47:2181";
	
	@ConfField("dubbo服务名称")
	private String applicationName = Constant.SYSTEM;
	
	@ConfField("dubbo暴露协议")
	private String protocolName = "dubbo";
	
	@ConfField("dubbo暴露端口")
	private Integer protocolPort = 20881;
}

smconf's People

Contributors

yinjihuan avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.