当前位置: 首页 > news >正文

教育培训官网/优化大师兑换码

教育培训官网,优化大师兑换码,宁夏建设局官方网站,融创中国最新消息前言在分布式系统中,由于服务数量巨多,为了方便服务配置文件统一管理,实时更新,所以需要分布式配置中心组件:spring-cloud-config ,它支持配置服务放在配置服务的内存中(即本地),也支持放在远程Git仓库中。…

前言

在分布式系统中,由于服务数量巨多,为了方便服务配置文件统一管理,实时更新,所以需要分布式配置中心组件:spring-cloud-config ,它支持配置服务放在配置服务的内存中(即本地),也支持放在远程Git仓库中。

本节主要演示怎么用Git仓库作为配置源。

创建配置项目

在github中创建一个项目,专门用来保存我们所有项目的配置文件,项目是我的项目结构

7d5b5b387a69a2221e92ffe16e1b7300.png

eureka-server.properties

eureka.client.register-with-eureka=false

eureka.client.fetch-registry=false

spring.application.name=eureka-server

server.port=18761

eureka.instance.hostname=peer1

eureka.client.serviceUrl.defaultZone=http://peer1:18761/eureka/

创建spring-cloud-config-server项目

项目结构如图:

08c41933ae730267374e133eef83723f.png

pom.xml核心代码

org.springframework.cloud

spring-cloud-config-server

SpringCloudConfigServerApplication.java

package com.cppba;

import org.springframework.boot.SpringApplication;

import org.springframework.boot.autoconfigure.SpringBootApplication;

import org.springframework.cloud.config.server.EnableConfigServer;

@SpringBootApplication

@EnableConfigServer

public class SpringCloudConfigServerApplication {

public static void main(String[] args) {

SpringApplication.run(SpringCloudConfigServerApplication.class, args);

}

}

application.properties

这个根据自己实际的git项目修改配置

server.port=8888

spring.application.name=config-server

spring.cloud.config.server.git.uri=https://github.com/bigbeef/cppba-config

spring.cloud.config.label=master

# spring.cloud.config.server.git.username=

# spring.cloud.config.server.git.password=

spring.cloud.config.server.git.searchPaths=\

cppba-spring-cloud/*,\

cppba-spring-cloud/eureka-client/*

spring.cloud.config.server.git.uri:配置git仓库地址

spring.cloud.config.server.git.searchPaths:配置仓库路径,以逗号隔开

spring.cloud.config.label:配置仓库的分支

spring.cloud.config.server.git.username:访问git仓库的用户名

spring.cloud.config.server.git.password:访问git仓库的用户密码

启动项目

访问地址:http://127.0.0.1:8888

http请求地址和资源文件映射如下:

/{application}/{profile}[/{label}]

/{application}-{profile}.yml

/{label}/{application}-{profile}.yml

/{application}-{profile}.properties

/{label}/{application}-{profile}.properties

根据我们自己的配置,我们可以这样访问:http://127.0.0.1:8888/eureka-server/default/master

application -> eureka-server (应用名)

profile -> default (启用的配置,通常是后缀,下面解释)

label -> master (分支)

访问到的结果就是:

582c9696c2c25674faef238faf916f59.png

profile比较重要,可以理解成读取哪些配置文件,假如我不止一个配置文件,可能会有:

eureka-server.properties(这个是通用配置文件,默认都会加载),

eureka-server-mysql.properties,

eureka-server-oracle.properties,

eureka-server-jpa.properties,

eureka-server-mysql.properties......

我们可能会选择性的加载其中的部分properties配置文件,那我们可以这样写:http://127.0.0.1:8888/eureka-server/default,mysql,jpa/master

到此,我们的spring-cloud-config-server就简单搭起来,后面的章节我会教大家怎么在项目中读取配置

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。

http://www.lbrq.cn/news/744193.html

相关文章:

  • 上海网站建设公司/seo网站营销公司哪家好
  • 西安 医疗网站建设/如何自制网站
  • 用明星名字做网站/seo属于运营还是技术
  • 跨境电子商务网站建设/网站制作公司官网
  • 做网站找哪个/廊坊百度推广电话
  • 网站后台文本编辑器/seo优化工具
  • 金启网站建设/找网络公司做推广费用
  • 网络在线培训网站建设方案/搜索引擎优化排名seo
  • 在建设部网站呢李可以看出需要什么时候考试/seo关键词排名优化哪好
  • 中土南方建设有限公司网站/seo引擎优化是什么
  • 深圳个人网站建设/营销网站
  • wordpress 响应速度慢/seo是什么意思 为什么要做seo
  • 网站页面统计代码是什么意思/苏州优化seo
  • 苏州专业网站设计/智能营销方法
  • 北京大型网站优化/抖音seo是什么意思
  • 销售网站建设价格/b站在线观看
  • 做网页网站怎么样/zac博客seo
  • 手机做任务网站有哪些/成都seo论坛
  • 做网站如何语音/网站推广
  • 外贸网站建设哪家公司好/nba赛程排名
  • 扬州有什么做网站的公司/分销渠道
  • 深圳网站建设制作公司/整站关键词快速排名
  • 天猫网站左侧导航用js怎么做/常熟网站建设
  • 个人网页html代码/成都网站seo性价比高
  • 网易网页游戏/推广优化工具
  • 自己怎么做淘宝客网站吗/百度扫一扫
  • 帮我注册一个账号/广州seo公司如何
  • 上海平台网站建设报/seo分析工具
  • 仓库管理系统er图/广告优化
  • 咋样着做自己的网站/找seo外包公司需要注意什么
  • 简笔成画:让AI绘画变得简单而有趣
  • 力扣 hot100 Day79
  • 4位量化:常规的线性层被替换成了4位线性层(48)
  • python numpy.random的基础教程(附opencv 图片转数组、数组转图片)
  • 《算法导论》第 32 章 - 字符串匹配
  • STM32 vscode 环境, 官方插件