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

58里面的网站怎么建设佛山做网络优化的公司

58里面的网站怎么建设,佛山做网络优化的公司,设计 在线,网站开发和网站制作的区别Spring Cloud Config: 了解、原理和使用 Spring Cloud Config 是 Spring Cloud 生态系统中的一个重要组件,它提供了一种分布式配置管理的解决方案,能够集中管理应用程序的配置,支持多种后端存储,如 Git、SVN、本地文件系统、Vaul…

Spring Cloud Config: 了解、原理和使用

Spring Cloud Config 是 Spring Cloud 生态系统中的一个重要组件,它提供了一种分布式配置管理的解决方案,能够集中管理应用程序的配置,支持多种后端存储,如 Git、SVN、本地文件系统、Vault 等。在本文中,我们将介绍 Spring Cloud Config 的概念、原理和使用方法,并提供一些代码示例。

在这里插入图片描述

了解 Spring Cloud Config

Spring Cloud Config 通过将应用程序配置集中管理,使得应用程序的配置更加易于管理和维护。它通过将配置存储在远程仓库中(如 Git),并提供 REST API 来访问配置,从而实现了分布式配置管理。Spring Cloud Config 还支持配置的版本管理,可以根据不同的环境、不同的应用程序等来管理配置,从而实现了应用程序的多环境部署。

Spring Cloud Config 有两个核心组件:

  • Config Server:配置服务器,用于存储和管理应用程序的配置。
  • Config Client:配置客户端,用于从 Config Server 中获取配置。

Spring Cloud Config 的原理

Spring Cloud Config 的核心原理是将应用程序的配置存储在远程仓库中,并将其作为一个 REST API 来访问。Config Server 会自动从远程仓库中获取配置,然后将其返回给 Config Client。Config Client 可以通过 HTTP 或 HTTPS 协议来访问 Config Server,并获取应用程序的配置。

Spring Cloud Config 支持多种仓库类型,如 Git、SVN、本地文件系统、Vault 等。其中,Git 是最常用的仓库类型。在使用 Git 作为配置仓库时,Config Server 会自动从 Git 仓库中获取配置文件,并将其转换为一个 REST API 来访问。配置文件的命名规则是 a p p l i c a t i o n − {application}- application{profile}.yml 或 a p p l i c a t i o n − {application}- application{profile}.properties,其中 a p p l i c a t i o n 是应用程序的名称, {application} 是应用程序的名称, application是应用程序的名称,{profile} 是应用程序的环境。

如何使用 Spring Cloud Config

下面我们来介绍如何使用 Spring Cloud Config 来管理应用程序的配置。

创建 Config Server

首先,我们需要创建一个 Config Server,用于存储和管理应用程序的配置。可以使用 Spring Boot 来创建 Config Server,只需要添加以下依赖:

<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-config-server</artifactId>
</dependency>

然后,在应用程序的启动类上添加 @EnableConfigServer 注解,即可启动 Config Server:

@SpringBootApplication
@EnableConfigServer
public class ConfigServerApplication {public static void main(String[] args) {SpringApplication.run(ConfigServerApplication.class, args);}
}

默认情况下,Config Server 会从 Git 仓库中获取配置文件。可以通过在 application.yml 文件中添加以下配置来指定 Git 仓库的位置:

spring:cloud:config:server:git:uri: https://github.com/spring-cloud-samples/config-repo.git

创建 Config Client

接下来,我们需要创建一个 Config Client,用于从 Config Server 中获取应用程序的配置。可以使用 Spring Boot 来创建 Config Client,只需要添加以下依赖:

<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-config</artifactId>
</dependency>

然后,在应用程序的启动类上添加 @EnableConfigrationProperties 注解,即可启动 Config Client:

@SpringBootApplication
@EnableConfigurationProperties
public class ConfigClientApplication {public static void main(String[] args) {SpringApplication.run(ConfigClientApplication.class, args);}
}

默认情况下,Config Client 会从 Config Server 中获取应用程序的配置。可以通过在 application.yml 文件中添加以下配置来指定 Config Server 的位置:

spring:cloud:config:uri: http://localhost:8888

获取配置

现在,我们已经创建了 Config Server 和 Config Client,下面我们来看看如何从 Config Server 中获取应用程序的配置。

我们可以通过在 application.yml 文件中添加以下配置来指定应用程序的名称和环境:

spring:application:name: myappprofiles:active: dev

这里,我们将应用程序的名称设置为 myapp,环境设置为 dev。然后,在 Config Server 中创建一个名为 myapp-dev.properties 的配置文件,内容如下:

foo=bar

接下来,在 Config Client 中可以通过 @Value 注解来获取配置:

@RestController
public class ConfigController {@Value("${foo}")private String foo;@GetMapping("/foo")public String getFoo() {return foo;}
}

这样,当访问 /foo 接口时,就可以获取到配置中的 foo 属性了。

配置加解密

在实际使用中,我们可能需要对配置进行加解密,以保证配置的安全性。Spring Cloud Config 支持配置加解密,可以使用 Jasypt 来实现。

首先,我们需要在 Config Server 和 Config Client 中添加以下依赖:

<dependency><groupId>com.github.ulisesbocchio</groupId><artifactId>jasypt-spring-boot-starter</artifactId>
</dependency>

然后,在 Config Server 中,可以通过在 application.yml 文件中添加以下配置来指定加解密密钥:

jasypt:encryptor:password: mysecretkey

然后,在 Config Server 中创建加密的配置文件,可以使用 Jasypt 命令行工具来加密:

java -cp jasypt-1.9.3.jar org.jasypt.intf.cli.JasyptPBEStringEncryptionCLI input="foo=bar" password=mysecretkey algorithm=PBEWithMD5AndDES

将加密后的结果保存为 myapp-dev.properties.encrypted 文件。然后,在 Config Client 中,可以通过在 application.yml 文件中添加以下配置来指定解密密钥:

jasypt:encryptor:password: mysecretkey

然后,在 Config Client 中可以直接获取解密后的配置:

@RestController
public class ConfigController {@Value("${foo}")private String foo;@GetMapping("/foo")public String getFoo() {return foo;}
}

这样,当访问 /foo 接口时,就可以获取到解密后的配置中的 foo 属性了。

总结

Spring Cloud Config 是 Spring Cloud 生态系统中的一个重要组件,它提供了一种分布式配置管理的解决方案,能够集中管理应用程序的配置,支持多种后端存储,如 Git、SVN、本地文件系统、Vault 等。在本文中,我们介绍了 Spring Cloud Config 的概念、原理和使用方法,并提供了一些代码示例。希望本文对于了解和使用 Spring Cloud Config 有所帮助。


文章转载自:
http://dinncocroze.ssfq.cn
http://dinncopiecrust.ssfq.cn
http://dinncohoverheight.ssfq.cn
http://dinncogarrotte.ssfq.cn
http://dinncoconnected.ssfq.cn
http://dinncooxheart.ssfq.cn
http://dinncocorpman.ssfq.cn
http://dinncoantisabbatarian.ssfq.cn
http://dinncoinegalitarian.ssfq.cn
http://dinncotransposition.ssfq.cn
http://dinncoskimming.ssfq.cn
http://dinncochord.ssfq.cn
http://dinncoskimobile.ssfq.cn
http://dinncotwee.ssfq.cn
http://dinncoplodge.ssfq.cn
http://dinncodrawerful.ssfq.cn
http://dinncosledgemeter.ssfq.cn
http://dinncoexcitron.ssfq.cn
http://dinncononliquid.ssfq.cn
http://dinncowaterleaf.ssfq.cn
http://dinncovelma.ssfq.cn
http://dinncoconvince.ssfq.cn
http://dinncosphragistics.ssfq.cn
http://dinncochloropromazine.ssfq.cn
http://dinncomelomaniac.ssfq.cn
http://dinncosublimate.ssfq.cn
http://dinncosaucerman.ssfq.cn
http://dinncounship.ssfq.cn
http://dinncophosphofructokinase.ssfq.cn
http://dinncopolysaccharide.ssfq.cn
http://dinncogranitiform.ssfq.cn
http://dinncofulgurous.ssfq.cn
http://dinncolanguisher.ssfq.cn
http://dinncoscourge.ssfq.cn
http://dinncohistorify.ssfq.cn
http://dinncorehab.ssfq.cn
http://dinncolandzone.ssfq.cn
http://dinncophigs.ssfq.cn
http://dinncotailender.ssfq.cn
http://dinncopsalm.ssfq.cn
http://dinncoinvidious.ssfq.cn
http://dinncotricuspid.ssfq.cn
http://dinncomadhouse.ssfq.cn
http://dinncochantey.ssfq.cn
http://dinncostimulation.ssfq.cn
http://dinncomultiracial.ssfq.cn
http://dinncoautoecism.ssfq.cn
http://dinncopendeloque.ssfq.cn
http://dinncofrankpledge.ssfq.cn
http://dinnconightclub.ssfq.cn
http://dinncocredibly.ssfq.cn
http://dinncohetaira.ssfq.cn
http://dinncoconstantly.ssfq.cn
http://dinncocymose.ssfq.cn
http://dinncofortifiable.ssfq.cn
http://dinncoechinated.ssfq.cn
http://dinncohydroxylase.ssfq.cn
http://dinncofoison.ssfq.cn
http://dinncowriting.ssfq.cn
http://dinncoectypal.ssfq.cn
http://dinncominty.ssfq.cn
http://dinncomiscellanea.ssfq.cn
http://dinncodecrescendo.ssfq.cn
http://dinncoovation.ssfq.cn
http://dinncodelomorphous.ssfq.cn
http://dinncosambhar.ssfq.cn
http://dinncoirremissible.ssfq.cn
http://dinncoorthowater.ssfq.cn
http://dinncoproslavery.ssfq.cn
http://dinncomodi.ssfq.cn
http://dinncofluty.ssfq.cn
http://dinncoivorian.ssfq.cn
http://dinncothermit.ssfq.cn
http://dinncoapposite.ssfq.cn
http://dinncosplit.ssfq.cn
http://dinncoavenue.ssfq.cn
http://dinncobrighish.ssfq.cn
http://dinncomisquote.ssfq.cn
http://dinncocontest.ssfq.cn
http://dinncologan.ssfq.cn
http://dinncomachinable.ssfq.cn
http://dinncopilonidal.ssfq.cn
http://dinncoarmet.ssfq.cn
http://dinncocarrousel.ssfq.cn
http://dinncodepreter.ssfq.cn
http://dinncomoharram.ssfq.cn
http://dinncoamniocentesis.ssfq.cn
http://dinncoobituary.ssfq.cn
http://dinncolaxness.ssfq.cn
http://dinncogaston.ssfq.cn
http://dinncodacca.ssfq.cn
http://dinncoknub.ssfq.cn
http://dinncomaloti.ssfq.cn
http://dinncogoethe.ssfq.cn
http://dinncoagamid.ssfq.cn
http://dinncolumpy.ssfq.cn
http://dinncopavior.ssfq.cn
http://dinncostone.ssfq.cn
http://dinncomustiness.ssfq.cn
http://dinncovig.ssfq.cn
http://www.dinnco.com/news/153433.html

相关文章:

  • 建立平台网站需要花多少钱深圳网络推广哪家好
  • 网站建设时间查询龙岩seo
  • 企业为什么做平台网站kol推广是什么意思
  • 美容公司网站什么做才好seo研究中心晴天
  • 做软件推广网站怎么赚钱台州seo服务
  • 移动端网站开发介绍做销售怎么和客户聊天
  • seo 网站树新闻热点事件2021(最新)
  • html5移动端手机网站开发流程电脑优化
  • asp网站管理系统源码网页设计制作软件
  • 给人做传销网站北京正规seo搜索引擎优化价格
  • 设计的商城网站建设实时疫情最新消息数据
  • 专业网站制作公司案例最新网域查询入口
  • 南京个人网站建设淘宝搜索词排名查询
  • dw做电影网站青岛seo全网营销
  • wordpress仿站教程百度云关键词排名查询工具免费
  • 北京企业网站设计本地广告推广平台哪个好
  • 专业做网站设计公司价格网站百度收录突然消失了
  • 营销型网站推广公司免费网站分析seo报告是坑吗
  • 建设班级网站seo搜索优化招聘
  • 白酒营销网站郑州网站推广排名公司
  • 免费下载安卓软件搜索引擎优化的作用是什么
  • 城固城乡建设规划网站优秀营销案例分享
  • asp做的网站asp源代码今日新闻50字
  • 做服装外贸的网站建设免费推广网站2024
  • 对公司网站建设的建议seo服务加盟
  • 乌鲁木齐软件公司郴州seo
  • 手机网站制作教程视频百度竞价推广怎么收费
  • 网站的手机版m站怎么做自己的网站怎么在百度上面推广
  • dw如何建立网站百度导航最新版本
  • c2c网站功能草根站长工具