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

环保业网站建设的策划兰州seo推广

环保业网站建设的策划,兰州seo推广,网站诊断分析案例,北京网站设计的公司一、介绍 (1)服务注册中心 (2)管理各个服务上的application.yml,支持动态修改,但不会影响客户端配置 (3)一般将application.yml文件放在git上,客户端通过http/https方式…

一、介绍

(1)服务注册中心
(2)管理各个服务上的application.yml,支持动态修改,但不会影响客户端配置
(3)一般将application.yml文件放在git上,客户端通过http/https方式拉取

二、项目搭建

(1)建个远程仓库,创建两个配置文件application.yml
在这里插入图片描述
(2)编写pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><parent><artifactId>demo20220821</artifactId><groupId>com.wsh.springcloud</groupId><version>1.0-SNAPSHOT</version></parent><modelVersion>4.0.0</modelVersion><artifactId>cloud-config-config3344</artifactId><dependencies><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-config-server</artifactId></dependency><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-netflix-eureka-client</artifactId></dependency><dependency><groupId>com.wsh.springcloud</groupId><artifactId>cloud-api-common</artifactId><version>1.0-SNAPSHOT</version></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency></dependencies>
</project>

(3)编写application.yml文件

server:port: 3344spring:application:name: cloud-config-servicecloud:config:server:git:uri: https://gitee.com/xxx/config.gitlabel: mastereureka:client:#    客户端设置为trueregister-with-eureka: true#    客户端设置为truefetch-registry: trueservice-url:#      defaultZone: http://localhost:7001/eurekadefaultZone: http://eureka1.com:7001/eureka, http://eureka2.com:7002/eurekainstance:instance-id: config3344prefer-ip-address: true

(4)编写启动类

package com.wsh.springcloud;import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.config.server.EnableConfigServer;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;/*** @ClassName ConfigMain3344* @Description: TODO* @Author wshaha* @Date 2023/10/15* @Version V1.0**/
@SpringBootApplication
@EnableEurekaClient
@EnableConfigServer
public class ConfigMain3344 {public static void main(String[] args) {SpringApplication.run(ConfigMain3344.class, args);}
}

(5)运行
在这里插入图片描述

三、客户端读取

(1)application.yml是用户级的,bootstrap.yml是系统级的,优先级更高
(2)编写pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"><parent><artifactId>demo20220821</artifactId><groupId>com.wsh.springcloud</groupId><version>1.0-SNAPSHOT</version></parent><modelVersion>4.0.0</modelVersion><artifactId>cloud-config-client3355</artifactId><dependencies><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-config</artifactId></dependency><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-netflix-eureka-client</artifactId></dependency><dependency><groupId>com.wsh.springcloud</groupId><artifactId>cloud-api-common</artifactId><version>1.0-SNAPSHOT</version></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency></dependencies>
</project>

(3)编写bootstrap.yml

server:port: 3355spring:application:name: cloud-config-client-servicecloud:config:label: master #分支名name: application # - 号前缀profile: prod # - 号后缀uri: http://localhost:3344 #配置中心地址eureka:client:#    客户端设置为trueregister-with-eureka: true#    客户端设置为truefetch-registry: trueservice-url:#      defaultZone: http://localhost:7001/eurekadefaultZone: http://eureka1.com:7001/eureka, http://eureka2.com:7002/eurekainstance:instance-id: configClient3355prefer-ip-address: true

(4)编写启动类

package com.wsh.springcloud;import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;/*** @ClassName ConfigMain3344* @Description: TODO* @Author wshaha* @Date 2023/10/15* @Version V1.0**/
@SpringBootApplication
@EnableEurekaClient
public class ConfigClientMain3355{public static void main(String[] args) {SpringApplication.run(ConfigClientMain3355.class, args);}
}

(5)编写Controller

package com.wsh.springcloud.controller;import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;/*** @ClassName ConfigClientController* @Description: TODO* @Author wshaha* @Date 2023/10/15* @Version V1.0**/
@RestController
public class ConfigClientController {@Value("${teset.name}")private String name;@RequestMapping("/getConfig")public String getConfig(){return name;}
}

(6)运行
在这里插入图片描述

四、手动刷新客户端配置

(1)暴露actuator

server:port: 3355spring:application:name: cloud-config-client-servicecloud:config:label: master #分支名name: application # - 号前缀profile: prod # - 号后缀uri: http://localhost:3344 #配置中心地址eureka:client:#    客户端设置为trueregister-with-eureka: true#    客户端设置为truefetch-registry: trueservice-url:#      defaultZone: http://localhost:7001/eurekadefaultZone: http://eureka1.com:7001/eureka, http://eureka2.com:7002/eurekainstance:instance-id: configClient3355prefer-ip-address: truemanagement:endpoints:web:exposure:include: "*"

(2)Controller增加注解@RefreshScope

package com.wsh.springcloud.controller;import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;/*** @ClassName ConfigClientController* @Description: TODO* @Author wshaha* @Date 2023/10/15* @Version V1.0**/
@RestController
@RefreshScope
public class ConfigClientController {@Value("${teset.name}")private String name;@RequestMapping("/getConfig")public String getConfig(){return name;}
}

(3)执行命令,必须是POST请求

curl -X POST "http://localhost:3355/actuator/refresh"
http://www.dinnco.com/news/28131.html

相关文章:

  • 做二手元器件那个网站查价格seo推广优化公司哪家好
  • 和coser做网站seo是什么单位
  • 优设网网站百度seo查询收录查询
  • 企业网站建设ppt宁波seo外包推广平台
  • 网站建设 b2b如何做百度搜索推广
  • 开发软件网站软文推广营销平台
  • 企业网站托管服务公司桂平网络推广
  • 河源手机网站制作个人网站免费域名和服务器
  • wpf入可以做网站吗最新营销模式有哪些
  • 秦皇岛网站制作 微商城建设seo排名工具外包
  • 简单网页的设计过程代哥seo
  • 网站建设日程表范文最强大的搜索引擎
  • 资讯网站 怎么做网站优化靠谱seo
  • 域名和网站的关系中国企业100强
  • 一个虚拟主机空间里放多个独立网站的方法seo信息网
  • 上海建设项目中标公示网站网页设计图片
  • 个人网站建立步骤搜索引擎推广实训
  • 在阿里云服务器搭建wordpress南宁seo做法哪家好
  • 用什么程序做网站好免费发布信息平台有哪些
  • 致力于网站开发维护学什么专业整站优化报价
  • 自己做网站排名sem和seo是什么意思
  • 简历旅游网站开发经验网络推广长沙网络推广
  • 做自己视频教程的网站2021年中国关键词
  • 图表统计类手机网站开发全网推广平台推荐
  • 哪些网站结构是不合理的迅速上排名网站优化
  • 像wordpress广州百度seo
  • 手机版网站模板 免费网络营销方式与工具有哪些
  • 正规电商平台seo综合查询站长工具怎么用
  • 成免费crm软件app重庆seo技术教程博客
  • 常州经开区建设局网站班级优化大师简介