Spring Cloud Config客户端使用
来源:互联网 发布:淘宝网上购物流程 编辑:程序博客网 时间:2024/04/30 09:44
要在应用程序中使用这些功能,只需将其构建为依赖于spring-cloud-config-client的Spring引导应用程序(例如,查看配置客户端或示例应用程序的测试用例)。添加依赖关系的最方便的方法是通过Spring Boot启动器org.springframework.cloud:spring-cloud-starter-config
。还有一个Maven用户的父pom和BOM(spring-cloud-starter-parent
)和用于Gradle和Spring CLI用户的Spring IO版本管理属性文件。示例Maven配置:
的pom.xml
<parent> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-parent</artifactId> <version>1.3.5.RELEASE</version> <relativePath /> <!-- lookup parent from repository --> </parent><dependencyManagement><dependencies><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-dependencies</artifactId><version>Brixton.RELEASE</version><type>pom</type><scope>import</scope></dependency></dependencies></dependencyManagement><dependencies><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-config</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency></dependencies><build><plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin></plugins></build> <!-- repositories also needed for snapshots and milestones -->
那么你可以创建一个标准的Spring Boot应用程序,像这个简单的HTTP服务器:
@SpringBootApplication@RestControllerpublic class Application { @RequestMapping("/") public String home() { return "Hello World!"; } public static void main(String[] args) { SpringApplication.run(Application.class, args); }}
当它运行它将从端口8888上的默认本地配置服务器接收外部配置,如果它正在运行。要修改启动行为,您可以使用bootstrap.properties
(如application.properties
)更改配置服务器的位置,但用于应用程序上下文的引导阶段),例如
spring.cloud.config.uri: http://myconfigserver.com
引导属性将在/env
端点中显示为高优先级属性源,例如
$ curl localhost:8080/env{ "profiles":[], "configService:https://github.com/spring-cloud-samples/config-repo/bar.properties":{"foo":"bar"}, "servletContextInitParams":{}, "systemProperties":{...}, ...}
(名为“configService:<远程存储库的URL> / <文件名>”的属性源包含值为“bar”的属性“foo”,是最高优先级)。源码来源
阅读全文
3 0
- Spring Cloud Config客户端使用
- Spring Cloud Config—客户端使用
- Spring Cloud Config—客户端
- spring cloud config使用
- spring cloud config 使用
- **Spring cloud config 配置本地属性供其它客户端使用
- spring cloud config使用总结
- Spring Cloud Config客户端配置细节
- spring cloud:spring cloud config
- 使用Spring Cloud Config搭建配置中心
- 使用Spring Cloud Config搭建配置中心
- 使用spring cloud config来统一管理配置文件
- 六、Spring Cloud系列:Config服务端与客户端常用配置
- 开始Spring Cloud Config
- Spring Cloud Config
- 关于spring cloud config
- Spring Cloud Config
- 开始Spring Cloud Config
- 手写gulp脚本打开本地浏览器支持mac,windows
- jdk配置环境变量+tomcat自启动(WINDOWS)
- MySQL 5.6关闭DNS查询
- 取消标题和状态栏
- Kotlin最佳项目实战——欧瑞天气App
- Spring Cloud Config客户端使用
- 激动人心!柳叶刀杂志执行主编回柳叶刀烧烤吃烧烤了!
- v9操作安装首页嵌套(上)
- 单例模式
- display的展示和隐藏
- python学习-Day2-pycharm的基本使用
- 分布式和集群的区别和联系
- jsp页面将时间截取精确到小时
- webview的一些应用