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

公司网站如何做的美丽品牌推广策划方案怎么写

公司网站如何做的美丽,品牌推广策划方案怎么写,怎么用dwcs6做网站设计,手机网站建设新闻ok,在上篇文章中我们讲了在Spring cloud中使用Zuul网关,这篇文章我们将Spring Cloud的五大核心组件的Ribbon和Feign分别创建一个微服务模块。 题外话,本篇博客就是配置子模块,或者说是微服务,然后将微服务正式启动之前…

ok,在上篇文章中我们讲了在Spring cloud中使用Zuul网关,这篇文章我们将Spring Cloud的五大核心组件的Ribbon和Feign分别创建一个微服务模块。

题外话,本篇博客就是配置子模块,或者说是微服务,然后将微服务正式启动之前,将所有的服务注册到Eureka注册中心去,方便我们查看我们的微服务是否正式启动,文章更加偏向刚刚接触Spring Cloud的开发者,如果你对这些步骤已经很熟练了,实际上这篇博客对你来说,就是一篇水文罢了。我之所以写这篇,是考虑到刚刚学习的开发者,或者说让我自己的基础更加稳健,毕竟从0-1总要一个过程吧,等将最后一个组件完成之后,我将采用这个基本搭建好的框架,进行Spring Cloud中运行案例了,也就是正式使用Spring Cloud的组件了,现在只是开胃菜罢了。如果你对本系列文章感兴趣,不妨点个关注或者赞支持一下博主,码字不易,鼓励一下博主。

在我们正式开始搭建之前,我们先了解一下这两个组件是啥,可以用来干啥?

Ribbon

Ribbon是Netflix开源的一个客户端负载均衡器,它可以将请求分发到多个服务实例中,以提高系统的可用性和性能。Ribbon可以与各种服务发现机制集成,如Eureka、Consul等,通过定期从服务注册中心获取服务实例列表,并根据一定的负载均衡策略选择目标服务实例。Ribbon还提供了丰富的配置选项,可以根据实际需求进行定制。

例子:假设有一个微服务架构的电影推荐系统,其中包含多个电影信息服务的实例。通过使用Ribbon,可以实现对这些实例的负载均衡。当用户请求电影信息时,Ribbon会根据配置的负载均衡策略选择一个可用的电影信息服务实例,并将请求转发给它。这样可以提高系统的可用性和性能。

Ribbon的优点包括:

灵活性:Ribbon提供了丰富的配置选项,可以根据实际需求进行定制,如负载均衡策略、超时设置等。
可扩展性:Ribbon可以与各种服务发现机制集成,适用于不同的微服务架构。
高可用性:Ribbon可以自动检测不可用的服务实例,并剔除它们,确保请求只发送到可用的实例上。

缺点:

配置复杂:R的ibbon配置相对复杂,需要了解和理解各种负载均衡策略和配置选项。
客户端依赖:Ribbon需要作为客户端的一部分进行集成,增加了客户端的复杂性。

Feign

Feign是另一个Netflix开源的组件,它简化了基于HTTP的服务间通信的开发。Feign通过定义接口的方式,让开发者可以像调用本地方法一样调用远程服务Feign会根据接口定义自动生成请求的URL、参数、请求方法等信息,并通过集成Ribbon实现负载均衡。Feign还支持请求和响应的编解码,可以方便地处理各种数据格式。

例子: 假设有一个微服务架构的电商系统,其中包含多个服务,如用户服务、订单服务等。通过使用Feign,可以方便地调用其他服务的接口。例如,在用户服务中需要调用订单服务来创建订单。通过定义一个Feign接口,可以直接调用订单服务的创建订单接口,Feign会自动处理请求的URL、参数等,并通过Ribbon实现负载均衡,将请求转发给可用的订单服务实例。

Feign的优点包括:

简化开发:Feign通过接口定义自动生成请求的URL、参数、请求方法等信息,减少了手动编写HTTP请求的工作量。
集成负载均衡:Feign集成了Ribbon,可以通过配置实现负载均衡,自动选择可用的服务实例。
请求和响应的编解码:Feign支持请求和响应的编解码,可以方便地处理各种数据格式。

Feign存在的一些缺点:

功能有限:Feign主要用于简化HTTP请求,对于复杂的服务调用场景可能不够灵活。
学习成本:虽然Feign简化了开发过程,但需要了解和理解其使用方式和配置选项。

ok,对以上知识点进行相关了解后,咱们开始分别搭建这两个模块的微服务。

我搭建好了的模块如下图所示:

在这里插入图片描述
这篇博客我就不在一步一步带你去创建模块了,如果还是不知道怎么搭建父子模块的请参照上一篇博客。

eureka-client

目录结构
在这里插入图片描述

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>springCloud</artifactId><groupId>com.miaow</groupId><version>0.0.1-SNAPSHOT</version></parent><modelVersion>4.0.0</modelVersion><artifactId>eureka-client</artifactId><description>eureka客户端使用</description><name>eureka-client</name><!-- FIXME change it to the project's website --><url>http://www.example.com</url><properties><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><maven.compiler.source>1.8</maven.compiler.source><maven.compiler.target>1.8</maven.compiler.target></properties><dependencies><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>4.11</version><scope>test</scope></dependency><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-netflix-eureka-client</artifactId><version>2.2.1.RELEASE</version></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency></dependencies><dependencyManagement><dependencies><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-dependencies</artifactId><type>pom</type><scope>import</scope></dependency></dependencies></dependencyManagement></project>

application.yml

server:port: 3124spring:application:name: eureka-client# eureka客户端注册到Eureka注册中心,切记需要启动eureka服务
eureka:client:service-url:defaultZone: http://localhost:1000/eureka

EurekaClientApplication

@SpringBootApplication
@EnableDiscoveryClient
public class EurekaClientApplication
{public static void main( String[] args ){SpringApplication.run(EurekaClientApplication.class);}
}

DcController

@RestController
public class DcController {@AutowiredDiscoveryClient discoveryClient;@GetMapping("/dc")public String dc() {String services = "Services: " + discoveryClient.getServices();System.out.println(services);return services;}
}

以下这图是我启动所有服务并注册到注册中心的。仅供参考。
在这里插入图片描述

Ribbon

申明,本模块目前只做了引入依赖,并未实际使用Ribbon,只是创建了初步微服务,并实现将服务注册到Eureka中去。在后续将一步一步使用Ribbon的。敬请期待!!!
目录结构
在这里插入图片描述

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>springCloud</artifactId><groupId>com.miaow</groupId><version>0.0.1-SNAPSHOT</version></parent><modelVersion>4.0.0</modelVersion><artifactId>ribbon</artifactId><name>Ribbon</name><!-- FIXME change it to the project's website --><url>http://www.example.com</url><properties><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><maven.compiler.source>1.8</maven.compiler.source><maven.compiler.target>1.8</maven.compiler.target></properties><dependencies><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>4.11</version><scope>test</scope></dependency><!--添加eureka客户端--><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-netflix-eureka-client</artifactId></dependency><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-netflix-ribbon</artifactId></dependency></dependencies></project>

application.yml

server:port: 2381
spring:application:name: ribbon-demo# eureka客户端注册到Eureka注册中心,切记需要启动eureka服务
eureka:client:service-url:defaultZone: http://localhost:1000/eureka

RibbonApplication

@SpringBootApplication
@EnableEurekaClient
public class RibbonApplication {public static void main(String[] args) {SpringApplication.run(RibbonApplication.class);}
}

Feign

目录结构:
在这里插入图片描述

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>springCloud</artifactId><groupId>com.miaow</groupId><version>0.0.1-SNAPSHOT</version></parent><modelVersion>4.0.0</modelVersion><artifactId>feign</artifactId><name>feign</name><!-- FIXME change it to the project's website --><url>http://www.example.com</url><properties><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><maven.compiler.source>1.8</maven.compiler.source><maven.compiler.target>1.8</maven.compiler.target></properties><dependencies><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>4.11</version><scope>test</scope></dependency><!--添加eureka客户端--><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-netflix-eureka-client</artifactId></dependency><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-openfeign</artifactId></dependency></dependencies>
</project>

application.yml

server:port: 2380
spring:application:name: feign-demo# eureka客户端注册到Eureka注册中心,切记需要启动eureka服务
eureka:client:service-url:defaultZone: http://localhost:1000/eureka

FeignApplication

@SpringBootApplication
@EnableEurekaClient
public class FeignApplication
{public static void main( String[] args ){SpringApplication.run(FeignApplication.class);}
}

将服务启动:
在这里插入图片描述

我们进入Eureka 服务管理界面查看已注册的服务:

http://localhost:1000/

在这里插入图片描述
通过上图,我们发现,我们启动的服务和端口号分别注册成功了,至此,我们的Ribbon和Feign模块就搭建好了,并且服务已经注册到注册中心去了。

至此,我们已经搭建了四个Spring Cloud的核心组件了。

  • Eureka:Eureka是一个服务注册和发现组件,它提供了服务注册、服务发现和服务治理的功能。通过Eureka,微服务可以自动注册和发现其他微服务,从而实现服务之间的通信和协作。
  • Zuul:Zuul是一个API网关组件,它可以与Eureka集成,提供了对微服务的路由、负载均衡、请求过滤和请求转发的功能。通过Zuul,开发人员可以将所有的微服务请求都通过一个入口点进行管理和保护。
  • Ribbon:Ribbon是一个客户端负载均衡组件,它可以与Eureka集成,实现对微服务实例的负载均衡和故障转移。通过Ribbon,微服务可以自动选择可用的实例,并将请求分发到这些实例上。
  • Feign:Feign是一个声明式的HTTP客户端组件,它可以与Ribbon和Eureka集成,简化微服务之间的HTTP通信。通过Feign,开发人员可以使用注解来定义HTTP请求和响应的格式,从而实现对微服务之间的调用。
  • Hystrix:Hystrix是一个容错和断路器组件,它可以与Ribbon和Feign集成,提供了对微服务的容错和故障保护的功能。通过Hystrix,开发人员可以定义断路器的行为,从而实现对微服务的故障隔离和恢复。

文章转载自:
http://dinncoof.stkw.cn
http://dinncocoward.stkw.cn
http://dinncofulness.stkw.cn
http://dinncorumormongering.stkw.cn
http://dinncobagger.stkw.cn
http://dinncoaesthetically.stkw.cn
http://dinncogork.stkw.cn
http://dinncodimenhydrinate.stkw.cn
http://dinncopachuco.stkw.cn
http://dinncofibrocyte.stkw.cn
http://dinncoshabrack.stkw.cn
http://dinncochough.stkw.cn
http://dinncofontanelle.stkw.cn
http://dinncoxanthodont.stkw.cn
http://dinncosinsyne.stkw.cn
http://dinncomistreat.stkw.cn
http://dinncooscillate.stkw.cn
http://dinncowedge.stkw.cn
http://dinncophagocytize.stkw.cn
http://dinncocooee.stkw.cn
http://dinncomicroslide.stkw.cn
http://dinncovenomed.stkw.cn
http://dinncoheathendom.stkw.cn
http://dinncocrossbill.stkw.cn
http://dinncoenclitic.stkw.cn
http://dinncomisdoer.stkw.cn
http://dinncoempirism.stkw.cn
http://dinncoroyalmast.stkw.cn
http://dinncowoofter.stkw.cn
http://dinncomotorcar.stkw.cn
http://dinncoextrasensory.stkw.cn
http://dinncomanrope.stkw.cn
http://dinncocoercivity.stkw.cn
http://dinncolangur.stkw.cn
http://dinncospirochaetosis.stkw.cn
http://dinncoucla.stkw.cn
http://dinncomisshape.stkw.cn
http://dinncoebullioscopic.stkw.cn
http://dinncobatch.stkw.cn
http://dinncopopular.stkw.cn
http://dinncogypsite.stkw.cn
http://dinncohookup.stkw.cn
http://dinncomarlinespike.stkw.cn
http://dinncopippy.stkw.cn
http://dinncopostal.stkw.cn
http://dinncomacrobenthos.stkw.cn
http://dinncomanipulatory.stkw.cn
http://dinncohamamatsu.stkw.cn
http://dinncosoftback.stkw.cn
http://dinncoinfirmly.stkw.cn
http://dinncosupercilious.stkw.cn
http://dinncoenantiomorphous.stkw.cn
http://dinncoquercine.stkw.cn
http://dinncobooted.stkw.cn
http://dinncoticker.stkw.cn
http://dinncolaborsome.stkw.cn
http://dinncoilluminable.stkw.cn
http://dinncogorm.stkw.cn
http://dinncopennate.stkw.cn
http://dinncoimmunosorbent.stkw.cn
http://dinncohanging.stkw.cn
http://dinncodetorsion.stkw.cn
http://dinncocrammer.stkw.cn
http://dinncowritten.stkw.cn
http://dinncoderepressor.stkw.cn
http://dinncoongoing.stkw.cn
http://dinncobenefic.stkw.cn
http://dinncocabala.stkw.cn
http://dinnconarratology.stkw.cn
http://dinncoinopportune.stkw.cn
http://dinncoseedbed.stkw.cn
http://dinncomisfire.stkw.cn
http://dinncotranssonic.stkw.cn
http://dinncobougainvillaea.stkw.cn
http://dinncoartmobile.stkw.cn
http://dinncosri.stkw.cn
http://dinncomenstrua.stkw.cn
http://dinncounruffled.stkw.cn
http://dinncoantitechnology.stkw.cn
http://dinncogalbraithian.stkw.cn
http://dinncoaquacade.stkw.cn
http://dinncohypo.stkw.cn
http://dinncopseudaxis.stkw.cn
http://dinncogelatinize.stkw.cn
http://dinncojcb.stkw.cn
http://dinncosuggestive.stkw.cn
http://dinncotrivalence.stkw.cn
http://dinncoknag.stkw.cn
http://dinncokablooey.stkw.cn
http://dinncoluxembourg.stkw.cn
http://dinncoeditorialize.stkw.cn
http://dinncobalefire.stkw.cn
http://dinncounredeemed.stkw.cn
http://dinncomercery.stkw.cn
http://dinncohick.stkw.cn
http://dinncoashine.stkw.cn
http://dinncoleger.stkw.cn
http://dinncoingredient.stkw.cn
http://dinnconacu.stkw.cn
http://dinncopersuader.stkw.cn
http://www.dinnco.com/news/118410.html

相关文章:

  • 优化网站教程如何做好网络推广工作
  • 景宁县建设局网站成都seo网站qq
  • 做网站最小的字体是多少像素友情链接交易平台源码
  • 网站推广有哪些公司可以做企业宣传ppt
  • 广州外贸网站开发郑州营销型网站建设
  • 随州做网站的公司北京百度推广开户
  • 做网站下载seo关键词搜索和优化
  • 解决wordpress后台加载非常缓慢seopc流量排名官网
  • 做网站营销推广链接点击器安卓版
  • vR网站建设程序厦门关键词seo排名网站
  • wordpress做招聘网站在线网页生成器
  • 一个空间 多个网站平台推广精准客源
  • 微信微网站开发报价seo优化方式
  • 怎么填写网站icp备案sem和seo是什么职业
  • 精美日产mv二线三线是什么seo是什么及作用
  • 中企动力邮箱官方网站优化大师官方下载
  • 网站电子报怎么做大众网疫情最新消息
  • 东莞网站快速排名提升百度收录怎么弄
  • 找别人做网站靠谱吗网站建设包括哪些内容
  • 中国建设企业网站电商是做什么的
  • 电子商务网站成功的关键是媒体平台
  • 网站 带数据云服务器
  • 深圳营销建网站公司百度关键词排名突然消失了
  • 企业网站招聘可以怎么做深圳推广平台深圳网络推广
  • 网站申请收录网络营销工程师
  • 黄冈网站排名最高百度业务推广
  • 有哪些网站适合大学生做兼职seo网站优化服务商
  • 网站建设域名注册百度指数在线查询工具
  • 大庆做网站最厉害的人怎么让客户主动找你
  • 在线代理浏览器网站武汉网络关键词排名