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

公司网站建设注意点网络工程的定义

公司网站建设注意点,网络工程的定义,国内比较大的源码网站,直播电商平台有哪些在之前的《Spring Cloud构建微服务架构#xff1a;分布式配置中心》一文中#xff0c;我们介绍的Spring Cloud Server配置中心采用了Git的方式进行配置信息存储。这一设计巧妙的利用Git自身机制以及其他具有丰富功能的Git服务端产品#xff0c;让Spring Cloud Server在配置存…在之前的《Spring Cloud构建微服务架构分布式配置中心》一文中我们介绍的Spring Cloud Server配置中心采用了Git的方式进行配置信息存储。这一设计巧妙的利用Git自身机制以及其他具有丰富功能的Git服务端产品让Spring Cloud Server在配置存储和管理的上避开了很多与管理相关的复杂实现使其具备了配置中心存储配置和读取配置的基本能力而更上层的管理机制由于不具备普遍适用性所以Spring Cloud Server并没有自己去实现这部分内容而是通过Git服务端产品来提供一部分实现如果还需要更复杂的功能也能自己实现与定义。即便如此对于Spring Cloud Server默认使用Git来存储配置的方案一直以来还是饱受争议。所以本文将介绍一下Spring Cloud Config从Edgware版本开始新增的一种配置方式采用数据库存储配置信息。 构建配置中心服务端 第一步创建一个基础的Spring Boot项目在pom.xml中引入几个主要依赖 spring-cloud-config-server配置中心的基础依赖spring-boot-starter-jdbc由于需要访问数据库所以需要加载jdbc的依赖mysql-connector-javaMySQL数据库的连接包flyway-core该内容非强制主要用来管理schema如果您不了解可以看一下这篇文章 parent groupIdorg.springframework.boot/groupId artifactIdspring-boot-starter-parent/artifactId version1.5.11.RELEASE/version relativePath//parentdependencies dependency groupIdorg.springframework.cloud/groupId artifactIdspring-cloud-config-server/artifactId /dependency dependency groupIdorg.springframework.boot/groupId artifactIdspring-boot-starter-jdbc/artifactId /dependency dependency groupIdorg.flywaydb/groupId artifactIdflyway-core/artifactId version5.0.3/version /dependency dependency groupIdmysql/groupId artifactIdmysql-connector-java/artifactId version5.1.21/version /dependency/dependenciesdependencyManagement dependencies dependency groupIdorg.springframework.cloud/groupId artifactIdspring-cloud-dependencies/artifactId versionEdgware.SR3/version typepom/type scopeimport/scope /dependency /dependencies/dependencyManagement第二步准备schema创建文件。在resources下创建schema目录并加入V1__Base_version.sql文件具体内容如下 CREATE TABLE properties ( id int(11) NOT NULL, key varchar(50) NOT NULL, value varchar(500) NOT NULL, application varchar(50) NOT NULL, profile varchar(50) NOT NULL, label varchar(50) NOT NULL, PRIMARY KEY (id)) ENGINEInnoDB DEFAULT CHARSETutf8;该脚本会在程序运行时由flyway自动执行 第三步创建应用主类具体如下 EnableConfigServerSpringBootApplicationpublic class ConfigServerBootstrap { public static void main(String[] args) { ApplicationContext context SpringApplication.run(ConfigServerBootstrap.class); // 测试用数据仅用于本文测试使用 JdbcTemplate jdbcTemplate context.getBean(JdbcTemplate.class); jdbcTemplate.execute(delete from properties); jdbcTemplate.execute(INSERT INTO properties VALUES(1, com.didispace.message, test-stage-master, config-client, stage, master)); jdbcTemplate.execute(INSERT INTO properties VALUES(2, com.didispace.message, test-online-master, config-client, online, master)); jdbcTemplate.execute(INSERT INTO properties VALUES(3, com.didispace.message, test-online-develop, config-client, online, develop)); jdbcTemplate.execute(INSERT INTO properties VALUES(4, com.didispace.message, hello-online-master, hello-service, online, master)); jdbcTemplate.execute(INSERT INTO properties VALUES(5, com.didispace.message, hello-online-develop, hello-service, online, develop)); }}这里增加了一些测试用数据以便于后续的配置读取验证。 第四步配置application.properties具体内容如下 spring.application.nameconfig-server-dbserver.port10020spring.profiles.activejdbcspring.cloud.config.server.jdbc.sqlSELECT KEY, VALUE from PROPERTIES where APPLICATION? and PROFILE? and LABEL?spring.datasource.urljdbc:mysql://localhost:3306/config-server-dbspring.datasource.usernamerootspring.datasource.passwordspring.datasource.driver-class-namecom.mysql.jdbc.Driverflyway.locations/schema这里主要涉及几个配置 spring.profiles.activejdbc必须设置将配置中心的存储实现切换到jdbc的方式spring.cloud.config.server.jdbc.sql非必须这里由于采用mysql数据源key、value是保留关键词原生的实现语句会报错所以需要重写一下这句查询语句如果存储的表结构设计不同于上面准备的内容也可以通过这个属性的配置来修改配置的获取逻辑spring.datasource.*存储配置信息的数据源配置这里采用mysql开发者根据自己实际情况修改flyway.locationsflyway加载schema创建sql的位置 服务端配置验证 完成了上一节内容之后我们就已经构建一个通过数据酷来存储配置内容的配置中心了下面我们可以通过配置中心暴露的端点来尝试读取配置。 第一步先将上面构建的配置中心启动起来。 第二步验证配置信息获取 curl http://localhost:10020/config-client/stage/获取信息config-client服务stage环境的配置内容根据上面的数据准备我们会获得如下返回内容 { name: config-client, profiles: [ stage ], label: null, version: null, state: null, propertySources: [ { name: config-client-stage, source: { com.didispace.message: test-stage-master } } ]}curl http://localhost:10020/hello-service/stage/develop获取信息hello-service服务stage环境develop标签的配置内容根据上面的数据准备我们会获得如下返回内容 { name: hello-service, profiles: [ online ], label: develop, version: null, state: null, propertySources: [ { name: hello-service-online, source: { com.didispace.message: hello-online-develop } } ]}关于如何访问Spring Cloud Config构建配置中心获取配置信息的详细内容可以查看前文《Spring Cloud构建微服务架构分布式配置中心》本文不做详细介绍。 总结 本文主要具体介绍了在Spring Cloud Config在Edgware版本开始新增的JDBC存储的使用思路具体使用实际上还有很多可以优化的空间比如索引的优化、查询语句的优化如果还需要进一步定制管理对于表结构的优化也是很有必要的。 最后安利一个基于Spring Cloud Config的配置管理项目https://github.com/dyc87112/spring-cloud-config-admin正在紧锣密鼓的开发中尽情期待 本文示例 读者可以根据喜好选择下面的两个仓库中查看config-server-db和config-client两个项目 Githubhttps://github.com/dyc87112/SpringCloud-Learning/Giteehttps://gitee.com/didispace/SpringCloud-Learning/ 如果您对这些感兴趣欢迎star、follow、收藏、转发给予支持
http://www.sadfv.cn/news/452534/

相关文章:

  • 浙江网站建设品牌设计linux wordpress 区别
  • 哪个网站可以做化学实验app关键词排名优化
  • 室内设计公司 网站建设男女做羞羞羞的事视频网站
  • 东莞电子商务网站建设商业营销厅装修公司
  • 网站弄论坛形式怎么做怎样做销售产品网站
  • 网站开发的技术要求学做网站是什么
  • 广州专业的网站开发公司网站根验证文件在哪
  • 沈阳市工伤网站做实开发小程序外包公司
  • wordpress+中文站模板网点地址信息获取错误:抖音默认地址未设置!
  • 杭州外贸网站建设公司排名昆明网页建站平台
  • 建设产品网站学院门户网站建设自评
  • 谷歌网站推广报价佛山市网络推广
  • 现在做网站用的软件网站运营发展前景
  • 网站建设的基础知识与维护wordpress 分库
  • 网站备案所需资料网站网页优化
  • 有没有工程外包的网站建筑公司名称大全简单大气两个字
  • 网站建设如何定位学校网站的服务器
  • 如何修改网站ico国外网站设计欣赏分析
  • 营销型网站建设哪家便宜厦门网络推广
  • 兼职网站推广如何做php网站开发需要多久
  • 网站优化竞争对手分析wordpress 建网站
  • 现在没人做网站了网站建设首页该放什么软件
  • 做自己的网站怎么赚钱wordpress 阿里云oss
  • 哈尔滨网站建设推广服务贵阳网站开发人员工资
  • 有没有代加工的网站WordPress只在手机
  • 检察院网站建设自查报告wordpress主题子主题运行速度
  • 网站建设软件kan一个公司做2个产品网站怎么做
  • 杭州网站制作建设图片上传网站源码
  • 企业网站建设需要多少钱wordpress plugin开发
  • 网站设计和内容上的不足和建议软件系统开发的大概步骤