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

怎么做网站需求分析应用商店oppo版本下载

怎么做网站需求分析,应用商店oppo版本下载,怎么判断网站开发语言,wordpress让收录本教程是关于Spring Cloud Config的#xff0c;这里我们将研究如何在不同的应用程序中针对不同的环境#xff08;例如开发人员#xff0c;本地#xff0c;产品等#xff09;使用Spring Cloud Config来管理和存储分布式外部配置属性。开发一个简单的云应用程序以使用云配置… 本教程是关于Spring Cloud Config的这里我们将研究如何在不同的应用程序中针对不同的环境例如开发人员本地产品等使用Spring Cloud Config来管理和存储分布式外部配置属性。开发一个简单的云应用程序以使用云配置外部化应用程序配置属性然后将同一应用程序扩展为使用发现服务器注册该应用程序在运行时更新配置以及对敏感属性进行加密和解密。 在分布式云系统中我们有许多较小的系统它们共同构成一个较大的系统因此我们有多个配置文件。 举例来说如果我们使用微服务则每个微服务都将拥有自己的配置文件并且由于可能运行多个实例并且这些配置管理面向部署因此在该应用程序中管理该配置变得很麻烦即使不错过它也具有挑战性。某些实例的任何配置更改。 为此Spring Cloud团队提供了易于实施的Spring Cloud配置它为分布式系统中的外部化配置提供了服务器和客户端支持。 使用Config Server您可以集中管理所有环境中应用程序的外部属性 Spring cloud config是一个Web应用程序它公开REST端点以访问配置属性它支持JSON属性和yaml等多种输出格式它支持的不同后备存储为gitdefaultSVN文件系统。 在我们的示例中我们将使用git作为配置属性的后备存储。 设置Git支持的商店 首先让我们建立我们的后备商店。 我们将使用github来存储我们的属性为此我在这里创建了一个简单的github项目来存储配置。 它基本上有3个.properties文件。 application.properties用于存储全局属性 spring-cloud-config-client.properties用于存储应用弹簧云配置客户端的全球性同样我们有spring-cloud-config-client-local.properties存储本地属性对于应用程序spring-cloud-config-client spring-cloud-config-client.properties server.contextPathspring-cloud-config-client test.propertyproperty from cloud config spring-cloud-config-client-local.properties test.local.propertytest local property 本地属性文件将具有配置属性以使用本地配置文件运行spring boot应用程序如果要在本地环境中覆盖全局配置文件例如DB属性则可以定义全局配置文件的现有属性。 Spring Cloud Config Server实施 这将是一个简单的spring boot应用程序。 对于此实现请首先从start.spring.io使用以下配置下载一个演示spring boot应用程序我们将在本教程后面的部分中使用发现服务器配置。 现在将其导入IDE您可以找到以下Maven配置。 pom.xml dependenciesdependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-actuator/artifactId/dependencydependencygroupIdorg.springframework.cloud/groupIdartifactIdspring-cloud-config-server/artifactId/dependencydependencygroupIdorg.springframework.cloud/groupIdartifactIdspring-cloud-starter-eureka-server/artifactId/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-test/artifactIdscopetest/scope/dependency /dependenciesdependencyManagementdependenciesdependencygroupIdorg.springframework.cloud/groupIdartifactIdspring-cloud-dependencies/artifactIdversion${spring-cloud.version}/versiontypepom/typescopeimport/scope/dependency/dependencies /dependencyManagement 让我们定义此应用程序的应用程序配置。 为了使我们的示例简单我们现在没有与发现服务器相关的配置。以下是我们在上一节中讨论的git URL。 application.properties server.port8888 spring.cloud.config.server.git.urihttps://github.com/only2dhir/config-repo.git 以下是我们主要的Spring Boot应用程序的实现。 在简单注释上– EnableConfigServer将启用spring cloud config所需的配置。 注意 –在运行此类之前您可以在pom.xml中注释eureka依赖关系以避免不必要的错误日志因为我们现在尚未进行任何与发现服务器相关的配置。 package com.devglan.springcloudconfigexample;import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.config.server.EnableConfigServer;SpringBootApplication EnableConfigServer public class SpringCloudConfigExampleApplication {public static void main(String[] args) {SpringApplication.run(SpringCloudConfigExampleApplication.class, args);} } 在类之上作为Java应用程序运行将暴露以下REST端点。 /{application}/{profile}[/{label}] /{application}-{profile}.yml /{label}/{application}-{profile}.yml /{application}-{profile}.properties /{label}/{application}-{profile}.properties 在这里application是应用程序的名称。 例如如果我们将客户端应用程序名称命名为spring-cloud-config-client则端点URL变为spring-cloud-config-client-dev.properties其中dev是spring boot活动配置文件。这里的标签是git brnach是可选参数。 Spring Cloud Config客户端实施 对于云配置客户端我们需要以下依赖项。稍后需要doscovery客户端进行服务发现。 现在spring-cloud-starter-config就足够了。 pom.xml dependenciesdependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactId/dependencydependencygroupIdorg.springframework.cloud/groupIdartifactIdspring-cloud-starter-config/artifactId/dependencydependencygroupIdorg.springframework.cloud/groupIdartifactIdspring-cloud-starter-eureka/artifactId/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-test/artifactIdscopetest/scope/dependency /dependenciesdependencyManagementdependenciesdependencygroupIdorg.springframework.cloud/groupIdartifactIdspring-cloud-dependencies/artifactIdversion${spring-cloud.version}/versiontypepom/typescopeimport/scope/dependency/dependencies /dependencyManagement 要使用客户端应用程序引导我们的Spring Cloud配置配置我们需要bootstrap.yml以下条目。 以下配置将为应用名称spring-cloud-config-client和本地配置文件调用属性配置文件并且我们的云配置服务器在http// localhost8888上运行 spring.application.namespring-cloud-config-client spring.profiles.activelocal spring.cloud.config.urihttp://localhost:8888 现在让我们定义我们的spring boot应用程序类。 SpringCloudConfigClientApplication.java package com.devglan.springcloudconfigclient;import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;SpringBootApplication public class SpringCloudConfigClientApplication {public static void main(String[] args) {SpringApplication.run(SpringCloudConfigClientApplication.class, args);} } 现在让我们定义我们的控制器类并使用Value注释通过Spring Cloud config使用外部属性。 DemoController.java package com.devglan.springcloudconfigclient.controller;import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController;RestController public class DemoController {Value(${test.property})private String testProperty;Value(${test.local.property})private String localTestProperty;RequestMapping(/)public String test() {StringBuilder builder new StringBuilder();builder.append(test property - ).append(testProperty).append( ).append(local property - ).append(localTestProperty);return builder.toString();} } 在属性文件中我们定义了test.property和test.local.property属性将其注入到控制器中。在属性文件中我们将server.contextPath定义为spring-cloud-config-client因此我们的客户端应用程序将是可从http// localhost8080 / spring-cloud-config-client /访问 将服务发现与Spring Cloud Config集成 在上一篇文章中我们使用spring-cloud-netflix-eureka创建了一个服务发现应用程序 。 我们将使用在默认端口8761上运行的同一发现服务器。要与发现服务器集成让我们首先编辑服务应用程序的application.properties文件以将自身注册为该服务器的服务。使用发现服务器将该应用程序注册为应用程序名称– spring-cloud-config-example application.properties spring.application.namespring-cloud-config-example eureka.client.service-url.defaultZonehttp://localhost:8761/eureka 使用EnableDiscoveryClient注释SpringCloudConfigExampleApplication.java 以便此应用程序向发现客户端注册自己。 此外我们需要在客户端应用程序中配置相同的内容以使用发现服务器来发现配置服务器。为此使用SpringCloudConfigClientApplication.java注释SpringCloudConfigClientApplication.java并在bootstrap.properties文件中进行以下条目以自动发现云配置服务。默认情况下云配置客户端会在发现服务器中使用任何发现配置服务器查找名称为configserver的应用程序但在我们的情况下云配置服务器的应用名称为spring-cloud-config-example因此在客户端中使用它来覆盖它属性spring.cloud.config.discovery.serviceId bootstrap.properties spring.application.namespring-cloud-config-client spring.profiles.activelocal #spring.cloud.config.urihttp://localhost:8888 spring.cloud.config.discovery.enabledtrue eureka.client.service-url.defaultZonehttp://localhost:8761/eureka spring.cloud.config.discovery.serviceIdspring-cloud-config-example 现在启动发现服务器然后启动云配置服务器再启动客户端应用程序然后访问http// localhost8080 / spring-cloud-config-client / 您可以期望获得与上述相同的结果。 因此总之首先启动发现服务器这会将端点公开为http// localhost8761 / eureka以注册服务。 现在当云配置服务器启动时它将使用服务ID spring-cloud-config-example注册其自身并将端点公开为http://192.168.1.6:8888/。 现在当客户端启动时它首先尝试解析配置属性。 为此它使用发现服务器来发现服务ID为spring-cloud-config-example的配置服务器。 此后解析基本URL然后将/{application}-{profile}.properties附加到该URL并获取配置属性。 最终网址变为– http// localhost8888 / spring-cloud-config-client-local.properties 在运行时更新云配置 这是spring cloud config的一项很酷的功能它可以在运行时更新配置属性而无需重新启动应用程序。 例如您可以更改日志级别。要在运行时更新云配置可以在git项目中更改配置属性然后推送到存储库。 然后我们可以将Spring Boot执行器/refresh端点或/bus/refresh与spring cloud总线一起使用或者将VCS / monitor与spring-cloud-config-monitor和spring-cloud-bus一起使用。 但是这样做不会刷新用Value或Bean注释的属性因为这些属性是在应用程序启动期间初始化的。 为了刷新这些属性spring提供了RefreshScope批注。我们将在下一篇文章中通过一个示例实现这一点– 运行时的Spring cloud config refresh属性 加密和解密敏感配置 这是spring cloud config所提供的另一个有用功能。数据库密码用户名等配置是敏感配置为此加密和解密spring提供了很多功能例如REST或飞行中的加密配置。使用对称和非对称密钥进行加密和解密。 我们将在下一个教程中创建一个示例应用程序其中包含有关此主题的示例。以下是一个示例应用程序.properties具有加密的配置。这是加密和解密敏感配置的完整配置 application.properties spring.datasource.usernameroot spring.datasource.password{cipher}ABCFGVH75858GFHDRT结论 在本教程中我们了解了Spring Cloud配置。 我们创建了我们的云配置服务器客户端和发现服务器以注册该服务。可以从此处下载源。如果您有任何要添加或共享的内容请在下面的评论部分中进行共享。 翻译自: https://www.javacodegeeks.com/2018/03/spring-cloud-configuration-externalize-application-configuration.html
http://wiki.neutronadmin.com/news/246748/

相关文章:

  • 有谁想做网站 优帮云做宠物商品的网站
  • 建设网站需要备案么小程序模板消息推送
  • 易语言跳到指定网站怎么做江西建设单位网站
  • 中英文网站开发费用最后的目的是什么
  • 网站生成静态重庆制片公司
  • 免费行情网站app下载大全层流病房建设单位网站
  • 网站排名优化外包微博个人网页设计模板
  • 微信商城和微网站建站哪家好 discuz
  • 广东网站备案进度查询成全视频在线看
  • 福田网站制作比较好的在网站图片源代码alt写入关键词后为什么不显示只显示title内容
  • 礼泉住房和城乡建设局网站科技公司网站首页
  • 专门做库存的网站广扬建设集团网站
  • wordpress表单提交的邮箱网站优化师负责干什么
  • 网站建设煊煊网安阳建设局网站
  • 网站怎么做才能赚钱微信公众帐号平台官网
  • 网站开发外包费用的会计分录阿里云网站域名证书
  • 网站功能需求说明做网页赚钱
  • 互联网app开发app优化建议
  • 做一网站要什么广州从化网站制作公司
  • 网站首页动画怎么做的没有域名怎么搭建网站
  • 相亲网站的女人 做直播的生活中实用的产品设计
  • 微网站怎么制作西安网站的设计说明
  • 唯尚广告联盟平台seo诊断报告怎么写
  • 做网站在哪里做比较好网站开发信息发布
  • 上海企业建站网站的意义做网站主页图片一般多少m
  • 网站开辟两学一做专栏做网站导航一般字号是多少
  • 中国建设培训网站查询系统青岛的seo服务公司
  • 大连建设执业资格注册中心网站2023年装修风格及颜色
  • 一站式企业服务平台是什么龙华区住房和建设局网站
  • phpcms 投资 网站源码设计软件网站