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

电子商务网站建设与实例网页设计培训贵不贵

电子商务网站建设与实例,网页设计培训贵不贵,汕头市区,手机网站导航栏特效我们前面接触到的spring cloud组件都是基于Netflix的组件进行实现的#xff0c;这次我们来看下spring cloud 团队自己创建的一个全新项目#xff1a;Spring Cloud Config.它用来为分布式系统中的基础设施和微服务提供集中化的外部配置支持#xff0c;分为服务端和客户端两个…我们前面接触到的spring cloud组件都是基于Netflix的组件进行实现的这次我们来看下spring cloud 团队自己创建的一个全新项目Spring Cloud Config.它用来为分布式系统中的基础设施和微服务提供集中化的外部配置支持分为服务端和客户端两个部分。 其中服务端也称为分布式配置中心他是独立的微服务应用用来连接配置仓库并为客户端提供获取接口(这些接口返回配置信息、加密、解密信息等) 客户端是微服务架构中的各个微服务应用或基础设施它们通过制定的配置中心来管理应用资源与业务相关的配置内容并在启动的时候从配置中心获取和加载配置信息。由于配置中心默认采用Git来存储配置信息因此我们会用到Git相关的内容如果没有用过Git或者忘记怎么用了可以参考下廖雪峰老师的Git教程。另外我自己用的Git远程仓库是码云。华丽的分割线接下来看下代码怎么实现。 一、准备远程Git仓库 在Gitee上新建一个项目https://gitee.com/sam-uncle/spring-cloud-learning在项目下新建子目录spring-cloud-config-file然后新建三个文件    内容分别是fromgit-dev-1.0、fromgit-test-1.0、fromgit-1.0新建一个分支config-lable-test新分支里面新建三个同名的文件不过内容分别是fromgit-dev-2.0、fromgit-test-2.0、fromgit-2.0  二、构建配置中心   先给出最终代码结构      搭建过程如下 新建maven工程config-server修改POM文件 project xmlnshttp://maven.apache.org/POM/4.0.0 xmlns:xsihttp://www.w3.org/2001/XMLSchema-instance xsi:schemaLocationhttp://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsdmodelVersion4.0.0/modelVersiongroupIdcom.sam/groupIdartifactIdconfig-server/artifactIdversion0.0.1-SNAPSHOT/versionparentgroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-parent/artifactIdversion1.5.1.RELEASE/version/parentpropertiesjavaVersion1.8/javaVersion/properties!-- 使用dependencyManagement进行版本管理 --dependencyManagementdependenciesdependencygroupIdorg.springframework.cloud/groupIdartifactIdspring-cloud-dependencies/artifactIdversionCamden.SR6/versiontypepom/typescopeimport/scope/dependency/dependencies/dependencyManagementdependencies!-- 引入config server依赖 --dependencygroupIdorg.springframework.cloud/groupIdartifactIdspring-cloud-config-server/artifactId/dependency/dependencies/project 创建启动类 /*** EnableConfigServer* * 开启Spring Cloud Config 的服务端功能**/ SpringBootApplication EnableConfigServer public class ConfigServerApp {public static void main(String[] args) {SpringApplication.run(ConfigServerApp.class, args);} } 配置application.properties文件指定远程仓库信息 server.port7001 spring.application.nameconfig-server#配置Git仓库的地址 spring.cloud.config.server.git.urihttps://gitee.com/sam-uncle/spring-cloud-learning/ #配置仓库路径下的相对搜索位置可以配置多个 spring.cloud.config.server.git.search-pathsspring-cloud-config-file #这里配置你的Git仓库的用户名 spring.cloud.config.server.git.username用户名 #这里配置你的Git仓库的密码 spring.cloud.config.server.git.password密码 启动并验证    访问配置信息的URL与配置文件的映射关系如下 /{application}/{profile} [/{label}]/{application}-{profile}.yml/{label}/{application}-{profile}.yml/{application}-{profile}.properties/{label}/{appliction}-{profile}.properties    上面的url会映射{application}-{profile}.properties对应的配置文件其中{label}对应Git上不同的分支默认是master。     通过浏览器访问http://localhost:7001/sam/dev/config-label-test,结果如下      三、实现客户端     最终代码结构         搭建过程如下 新建maven工程config-client修改POM文件 project xmlnshttp://maven.apache.org/POM/4.0.0xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsdmodelVersion4.0.0/modelVersiongroupIdcom.sam/groupIdartifactIdconfig-client/artifactIdversion0.0.1-SNAPSHOT/versionparentgroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-parent/artifactIdversion1.5.1.RELEASE/version/parentpropertiesjavaVersion1.8/javaVersion/properties!-- 使用dependencyManagement进行版本管理 --dependencyManagementdependenciesdependencygroupIdorg.springframework.cloud/groupIdartifactIdspring-cloud-dependencies/artifactIdversionCamden.SR6/versiontypepom/typescopeimport/scope/dependency/dependencies/dependencyManagementdependencies!-- 引入config依赖 --dependencygroupIdorg.springframework.cloud/groupIdartifactIdspring-cloud-starter-config/artifactId/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactId/dependency/dependencies/project 创建启动类 SpringBootApplication public class ConfigClientApp {public static void main(String[] args) {SpringApplication.run(ConfigClientApp.class, args);}} 配置bootstrap.properties文件指定config-server位置 server.port7002 #{application} spring.application.namesam #{profile} spring.cloud.config.profiledev #{label} spring.cloud.config.labelmaster#config server uri spring.cloud.config.urihttp://localhost:7001/ 创建controller RefreshScope RestController public class TestController {/*** 通过Value 来讲配置文件中的值写入到代码中*/Value(${from})private String from;RequestMapping(/from)public String from() {return from;} } 启动并测试       四、工作原理Spring Cloud Config配置中心的工作原理如下 客户端启动时根据bootstrap.properties中配置的应用名{application}、环境名{profile}、分支名{label}向Config Server请求获取配置信息。Config Server根据自己维护的Git仓库信息和客户传递过来的配置定位信息去查找配置信息。通过git clone命令将找到的配置信息下载到本地Config Server的文件系统中。在通过页面访问或启动客户端的时候我们在服务端能看到如下下载的log 2018-05-14 22:51:58.055 INFO 3084 --- [nio-7001-exec-1] o.s.c.c.s.e.NativeEnvironmentRepository : Adding property source: file:/C:/Users/sam/AppData/Local/Temp/config-repo-8627749771720918793/spring-cloud-config-file/sam-dev.properties 2018-05-14 22:51:58.055 INFO 3084 --- [nio-7001-exec-1] o.s.c.c.s.e.NativeEnvironmentRepository : Adding property source: file:/C:/Users/sam/AppData/Local/Temp/config-repo-8627749771720918793/spring-cloud-config-file/sam.properties Config Server创建Spring 的ApplicationContext实例并从Git本地仓库中加载配置文件最后将这些配置内容读取出来返回给客户端。客户端在获取外部配置信息后加载到客户端的applicationContext实例。转载于:https://www.cnblogs.com/sam-uncle/p/9036053.html
http://www.pierceye.com/news/297609/

相关文章:

  • 安徽省建设厅八大员报名网站网页设计兼职平台
  • 网站建设专利个人备案网站可以做商城展示
  • 北京做网站好的公司南充建设企业网站
  • 做一个静态网站要多少钱龙岗区网站建设
  • 安徽网站建设开发电话万网 网站模板
  • 网站响应式设计域名注册服务商
  • 焦作公司做网站小程序开发教程视频 推荐
  • php网站做代理服务器室内设计公司招聘
  • 做招标投标网站如何张家口专业做网站公司
  • 做网站广告中敏感词会涉及到工商彩票网站开发. 极云
  • 怎么做网站数据库东莞本地招聘网站有哪些
  • 网站维护中是不是关闭网站了无货源电商软件
  • 用英文字母做网站关键词flash网站建设个人简介
  • 百度做商务网站多少钱wordpress编辑器文字颜色
  • 乌市正规网站建设网站内页301重定向怎么做
  • 手机网站 跳转把开发的网站让外网能访问要怎么做
  • 网站优化建设扬州网站的不同类
  • 为什么做电影网站没有流量仙桃网站设计
  • 个人站长做哪些网站好开发app软件怎么挣钱
  • 求免费网站能看的2021建立网站要什么条件和多少钱
  • 温州网站推广优化wordpress实用的插件
  • 烟台做网站找哪家好企业网站建设品牌
  • 无备案网站做cdnwordpress ishome
  • 国外营销企业网站公司的网站建设服务费
  • 外包做网站的要求怎么写一站式网站建设平台
  • 太原做网站联系方式番禺人才网招聘网
  • 怎样推广一个网站东莞市建设工程检测中心网站
  • 哪个网站做招聘海报比较好搜索公众号
  • 外包给网站建设注意事项营销方法有哪些方式
  • 提供手机网站制作公司网站建设与域名建设