当前位置: 移动技术网 > 科技>人工智能>云计算 > SpringCloudConfig(一.启动SpringCloudConfigServer)

SpringCloudConfig(一.启动SpringCloudConfigServer)

2018年02月20日  | 移动技术网科技  | 我要评论

Spring CLoud Config 是在一个分布式系统中给server端和client端提供注册功能的一个组件。Config server可以为分布式应用集中管理外部配置的属性。有了这个集中配置的地方,一个应用程序可以从dev到test再到production迁移的过程中不需要任何配置就可以运行。
下面开始试试Spring Cloud Config.
Spring Cloud Config 是一个Spring boot程序,我要先下载源码,然后编译。
git clone https://github.com/spring-cloud/spring-cloud-config.git

然后就是编译了,编译自然是用maven去编,具体maven的使用不是本文的重点,可以自行百度,当然maven依赖于Java,需要先安装jdk,如果maven下载速度慢可以配置maven的源为阿里源,请参照:
http://blog.csdn.net/qq_21460229/article/details/71374938
当下载完源码后进入源码目录进行编译。
cd spring-cloud-config/spring-cloud-config-server
../mvnw spring-boot:run
也可以用sts集成环境导入spring-cloud-config源码,然后编译,效果和命令行是一样的
当然第一次会下载很多依赖包,要等一会,所以去喝杯茶,回头在回来看。
当编译完成之后spring-cloud-config-server就启动了,端口是8888.

浏览器访问:http://localhost:8888/foo/development

{
    "name": "foo",
    "profiles": [
        "development"
    ],
    "label": null,
    "version": "a611374438e75aa1b9808908c57833480944e1a8",
    "state": null,
    "propertySources": [
        {
            "name": "https://github.com/spring-cloud-samples/config-repo/foo-development.properties",
            "source": {
                "bar": "spam",
                "foo": "from foo development"
            }
        },
        {
            "name": "https://github.com/spring-cloud-samples/config-repo/foo.properties",
            "source": {
                "foo": "from foo props",
                "democonfigclient.message": "hello spring io"
            }
        },
        {
            "name": "https://github.com/spring-cloud-samples/config-repo/application.yml",
            "source": {
                "info.description": "Spring Cloud Samples",
                "info.url": "https://github.com/spring-cloud-samples",
                "eureka.client.serviceUrl.defaultZone": "http://localhost:8761/eureka/",
                "foo": "baz"
            }
        }
    ]
}

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网