spring cloud系列一 搭建配置服务器(分布式配置管理)configserver
来源:互联网 发布:用ps做淘宝主图 编辑:程序博客网 时间:2024/06/06 07:46
分布式配置管理应该是分布式系统和微服务应用的第一步。想象一下如果你有几十个服务或应用需要配置,而且每个服务还分为开发、测试、生产等不同维度的配置,那工作量是相当大的,而且还容易出错。如果能把各个应用的配置信息集中管理起来,使用一套机制或系统来管理,那么将极大的提高系统开发的生产效率,同时也会提高系统开发环境和生产环境运行的一致性。
1、pom.xml
<parent>
<groupId>org.springframework.boot</groupId> 引入boot
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.4.RELEASE</version>
</parent>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>引入spring cloud
<artifactId>spring-cloud-dependencies</artifactId>
<version>Dalston.SR2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>引入config-server jar
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
</dependencies>
2、启动类
@SpringBootApplication
@EnableConfigServer
public class ConfigServerApplication {
public static void main(String[] args) {
SpringApplication.run(ConfigServerApplication.class, args);
}
}
3、配置文件
=====application.properties
server.port=8888
#spring.cloud.config.server.git.uri=http://git.oschina.net/zhou666/spring-cloud-7simple/tree/master/cloud-config-repo
#spring.cloud.config.server.git.searchPaths=cloud-config-repo
#eureka.client.serviceUrl.defaultZone=http\://localhost\:8761/eureka/,http\://zlhost\:8762/eureka/
spring.application.name=config-server
#使用本地属性文件
spring.profiles.active = native
#属性文件地址,只要指定文件夹的路径
spring.cloud.config.server.native.searchLocations=classpath:/properties/
====configServer-dev.properties
spring.datasource.url: jdbc:mysql://localhost/test
#spring.datasource.url = jdbc:h2:file:~/.h2/testdb
spring.datasource.username: root
spring.datasource.password: root
driver-class-name: com.mysql.jdbc.Driver
spring.jpa.database=MySQL
spring.jpa.show-sql=true
spring.jpa.generate-ddl=true
spring.jpa.hibernate.ddl-auto=update
spring.jpa.hibernate.naming_strategy=org.hibernate.cfg.ImprovedNamingStrategy
4、浏览器访问
http://127.0.0.1:8888/configServer/dev
5、客户端使用configserver
pom.xml
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
配置bootstrap.properties
#指定配置中心
spring.cloud.config.uri:http://127.0.0.1:8888
#指定属性文件名 configServer-dev.properties,是有命名规则的
spring.cloud.config.name=configServer
spring.cloud.config.profile=${profile:dev}
- spring cloud系列一 搭建配置服务器(分布式配置管理)configserver
- Spring Cloud之ConfigServer
- spring cloud学习笔记(一):配置服务器搭建
- 使用spring cloud实现分布式配置管理
- 使用spring cloud实现分布式配置管理
- javaweb——spring cloud分布式系统(1)搭建配置管理中心
- 一、Spring Cloud系列:Zipkin服务端配置
- spring cloud config整合gitlab搭建分布式的配置中心
- spring cloud config整合gitlab搭建分布式的配置中心
- Spring Cloud学习系列第五章:分布式系统外部配置Spring Cloud Config
- Hadoop系列~环境搭建,单机/伪分布式配置(一)
- Spring Cloud学习 -- 配置管理
- spring cloud系列-02.配置中心Config搭建
- 微服务架构之spring cloud (一)分布式配置中心
- Spring Cloud构建微服务架构(一)分布式配置中心
- 干货实操:微服务Spring Cloud 系列(一) Spring cloud Config 用SVN做配置仓库
- SpringCloud(第 028 篇)ConfigServer 配置管理微服务
- (一)spring cloud分布式云服务架构
- 记2017年上交软院优才夏令营
- Docker 搭建开发环境
- Win7快捷键17
- 织梦(dedecms)后台删除文章后台还有分页显示解决方法
- Spring Boot Admin
- spring cloud系列一 搭建配置服务器(分布式配置管理)configserver
- 新特性总结-JDK1.8
- POJ 3463 Sightseeing dijkstra
- 2506-完美网络
- 找不到类库
- Java多线程一般用法
- 神经网络入门
- 打造万能的ListView GridView 适配器
- 读取机器人反馈数据,控制机器人状态