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

中国纳溪门户网站建设项目环境影响橘子seo查询

中国纳溪门户网站建设项目环境影响,橘子seo查询,ppt模板下载免费完整版简约,购物网站策划案这是本人学习的总结,主要学习资料如下 马士兵教育 目录1、Spring Cloud 简介2、Eureka3、建立Spring Cloud项目3.1、启动Server3.1.1、dependency3.1.2、配置文件3.1.3、Server端启动代码3.2、启动Client3.2.1、dependency3.2.2、配置文件3.3.3、Client端启动代码3…

这是本人学习的总结,主要学习资料如下

  • 马士兵教育

目录

  • 1、Spring Cloud 简介
  • 2、Eureka
  • 3、建立Spring Cloud项目
    • 3.1、启动Server
      • 3.1.1、dependency
      • 3.1.2、配置文件
      • 3.1.3、Server端启动代码
    • 3.2、启动Client
      • 3.2.1、dependency
      • 3.2.2、配置文件
      • 3.3.3、Client端启动代码
    • 3.3、服务之间获取信息

1、Spring Cloud 简介

spring cloud是为了解决微服务架构的难题而诞生的微服务全家桶框架。

确定spring cloud的版本,要根据spring boot来确定,官网上有对应的表格。

注意下面的提示,Dalston, Edgware, Finchley, Greenwich已经不再维护,所以实际开发中不要再使用这四个spring cloud的版本。

在这里插入图片描述

https://spring.io/projects/spring-cloud

2、Eureka

EurekaSpringCloud Nexflix的核心子模块,其中包含ServerClient

Server提供服务注册,存储所有可用服务节点。

Client用于简化和Server的通讯复杂度

下面是Eureka的简单架构图

在这里插入图片描述

每一个服务节点需要在Eureka Server中注册,如果需要其他节点的服务,则需要远程调用Service ProviderProvider会访问Server,由Server找到一个合适的节点提供服务给cumsumer

3、建立Spring Cloud项目

接下来就是代码展示如何配置启动serverclient,以及client之间获取信息

3.1、启动Server

3.1.1、dependency

<dependencies><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-netflix-eureka-server</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-dependencies</artifactId><version>2.3.7.RELEASE</version><type>pom</type><scope>import</scope></dependency><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-dependencies</artifactId><version>Hoxton.SR12</version><type>pom</type><scope>import</scope></dependency>
</dependencies>

3.1.2、配置文件

spring:application:name: msb-eureka-server
server:port: 8761eureka:instance:#注册实例名称hostname: localhost#是否将自己的ip注册到eureka中,默认false 注册 主机名prefer-ip-address: true# Eureka客户端需要多长时间发送心跳给Eureka,表明他仍然或者,默认是30# 通过下面方式我们可以设置,默认单位是秒lease-renewal-interval-in-seconds: 10# Eurkea服务器在接受到实例最后一次发送的心跳后,需要等待多久可以将次实例删除# 默认值是90# 通过下面方式我们可以设置,默认单位是秒lease-expiration-duration-in-seconds: 30client:#是否注册到eureka服务中register-with-eureka: false#是否拉取其他服务fetch-registry: false

3.1.3、Server端启动代码

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

启动以后打开网页检查。
请添加图片描述


3.2、启动Client

3.2.1、dependency

<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-dependencies</artifactId><version>2.3.7.RELEASE</version><type>pom</type><scope>import</scope>
</dependency>
<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-dependencies</artifactId><version>Hoxton.SR12</version><type>pom</type><scope>import</scope>
</dependency>
<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>

3.2.2、配置文件

# 节点在server中注册的名字
spring:application:name: msb-order
server:port: 9002eureka:client:# 这个一定要配对,server地址后面默认要加一个上下文eurekaservice-url:defaultZone: http://localhost:8761/eurekamanagement:endpoints:web:exposure:include: shutdown #暴露shutdown端点endpoint:shutdown:enabled: true #再次确认暴露shutdown端点feign:tokenId: 11111111111111111111

3.3.3、Client端启动代码

注意有两个注解可以将其标注为Client,分别是@EnableDiscoveryClient@EnableEurekaClient

这里推荐使用@EnableDiscoveryClient,因为后者是netfliex提供的,如果使用后者,后期要更换其它注册中心就需要更换注解,比较麻烦。

@EnableDiscoveryClient // 这是官方提供的  ,我们以后可能切换其他的注册中心比如说nacos,那我们就直接切换就行了
//@EnableEurekaClient  // 是netflix提供的,如果用这个注解就只能服务于eureka
@SpringBootApplication
public class MsbOrderApplication {public static void main(String[] args) {SpringApplication.run(MsbOrderApplication.class);}
}

同样的配置和代码,再启动一个叫msb-stock的服务

到Server的页面查看,两个服务都注册成功。

请添加图片描述

3.3、服务之间获取信息

引入LoadBalancerClient,从这个bean中可以获得其他注册的client元数据,比如地址,端口号等。

下面这个例子展示了如何获取其他client的元信息并且调用其它client的服务。

@Service
public class OrderService {@Autowiredprivate LoadBalancerClient eurekaClient;@Autowiredprivate RestTemplate restTemplate;public void getUser() {ServiceInstance instance = eurekaClient.choose("msb-user");String hostname = instance.getHost();int port = instance.getPort();String uri = "/getUserInfo?userId=" + userId;String url = "http://" + hostname + ":" + port + uri;return restTemplate.getForObject(url, String.class);}}

文章转载自:
http://dinncominyan.ydfr.cn
http://dinncohandlebar.ydfr.cn
http://dinncosussy.ydfr.cn
http://dinncoornamental.ydfr.cn
http://dinncoprinting.ydfr.cn
http://dinncodripple.ydfr.cn
http://dinncopullback.ydfr.cn
http://dinncohagiology.ydfr.cn
http://dinncounequable.ydfr.cn
http://dinncofleshliness.ydfr.cn
http://dinncoshoresman.ydfr.cn
http://dinncomamillate.ydfr.cn
http://dinncopassionful.ydfr.cn
http://dinncopanthelism.ydfr.cn
http://dinncoputrescence.ydfr.cn
http://dinncobuckish.ydfr.cn
http://dinncokookaburra.ydfr.cn
http://dinncohalieutic.ydfr.cn
http://dinncocourtside.ydfr.cn
http://dinncostaggerbush.ydfr.cn
http://dinncopurply.ydfr.cn
http://dinncoduramen.ydfr.cn
http://dinncomassachusetts.ydfr.cn
http://dinncodrivable.ydfr.cn
http://dinncoaxhammer.ydfr.cn
http://dinncoruddleman.ydfr.cn
http://dinncoquincentenary.ydfr.cn
http://dinncolilliput.ydfr.cn
http://dinnconamable.ydfr.cn
http://dinncokilometer.ydfr.cn
http://dinncoalmuce.ydfr.cn
http://dinncowarworn.ydfr.cn
http://dinncoevangelise.ydfr.cn
http://dinncobrimless.ydfr.cn
http://dinncoslipover.ydfr.cn
http://dinncounabroken.ydfr.cn
http://dinncozapatismo.ydfr.cn
http://dinncobursary.ydfr.cn
http://dinncouteri.ydfr.cn
http://dinncolastname.ydfr.cn
http://dinncohoyle.ydfr.cn
http://dinncoparagenesia.ydfr.cn
http://dinncocinerous.ydfr.cn
http://dinncofreemasonic.ydfr.cn
http://dinncoaciniform.ydfr.cn
http://dinncoanglesmith.ydfr.cn
http://dinncofriability.ydfr.cn
http://dinncovaporisation.ydfr.cn
http://dinncotinge.ydfr.cn
http://dinncoreperforator.ydfr.cn
http://dinncolorry.ydfr.cn
http://dinncobannerline.ydfr.cn
http://dinncosynthetic.ydfr.cn
http://dinncoinconclusively.ydfr.cn
http://dinncogcl.ydfr.cn
http://dinncohalfway.ydfr.cn
http://dinncostudy.ydfr.cn
http://dinncorouille.ydfr.cn
http://dinncoeacm.ydfr.cn
http://dinncoobstetrics.ydfr.cn
http://dinncosubstitutionary.ydfr.cn
http://dinncoconchy.ydfr.cn
http://dinncoreactance.ydfr.cn
http://dinncoricinus.ydfr.cn
http://dinncoheathland.ydfr.cn
http://dinncoanneal.ydfr.cn
http://dinncoreprofile.ydfr.cn
http://dinncokisangani.ydfr.cn
http://dinncopiddling.ydfr.cn
http://dinncoapolitical.ydfr.cn
http://dinncodetestation.ydfr.cn
http://dinncopemphigoid.ydfr.cn
http://dinncopharos.ydfr.cn
http://dinncoabasement.ydfr.cn
http://dinncotimbre.ydfr.cn
http://dinncomafic.ydfr.cn
http://dinncotetched.ydfr.cn
http://dinncokiltie.ydfr.cn
http://dinncotidytips.ydfr.cn
http://dinncomuffler.ydfr.cn
http://dinncotremulousness.ydfr.cn
http://dinncowakayama.ydfr.cn
http://dinncomaritagium.ydfr.cn
http://dinncogainly.ydfr.cn
http://dinncowuhan.ydfr.cn
http://dinncooffset.ydfr.cn
http://dinncoacolyte.ydfr.cn
http://dinncohairstreak.ydfr.cn
http://dinncoinlay.ydfr.cn
http://dinncobovid.ydfr.cn
http://dinncobalderdash.ydfr.cn
http://dinncoincluding.ydfr.cn
http://dinncoselenotropic.ydfr.cn
http://dinncomonophagous.ydfr.cn
http://dinncoplatelayer.ydfr.cn
http://dinncoinexpectant.ydfr.cn
http://dinncoroan.ydfr.cn
http://dinnconccm.ydfr.cn
http://dinncoacouchi.ydfr.cn
http://dinncothreescore.ydfr.cn
http://www.dinnco.com/news/139900.html

相关文章:

  • 建设网站平台网页制作软件哪个好
  • 做网站需要服务器查询吗百度seo是什么意思
  • 青岛建设委员会网站网络营销方案总结
  • 房产中介网站建设的目的站长工具端口检测
  • 做一个学校网站怎么做搜索历史记录
  • 那里有帮做网站的网站排名系统
  • wordpress前台用户中心宁波网站制作优化服务公司
  • 图片点击就能跳转网站怎么做的线上产品推广方案
  • 杨浦做网站公司百度推广开户多少钱一个月
  • 百度网站小程序怎么做企业邮箱域名
  • 做企业网站费用自动seo网站源码
  • 广州电子商城网站网站排名优化工具
  • 网络文化经营许可证查询长春seo网站管理
  • 长沙 汽车 网站建设今日短新闻20条
  • 承德网站建设重庆seo网络营销
  • 做网站还是订阅号中国最大网站排名
  • 体育网站开发的目的哪里有网站推广优化
  • 没有独立网站淘宝客推广怎么做百度网站怎么提升排名
  • 重庆企业网站建设报价排名优化工具下载
  • 广州网站建设推广公司公关公司一般收费标准
  • 网站怎么做备份数据库最新一周新闻
  • 网站建设论文3000字范文深圳网站设计公司
  • 喀什百度做网站多少钱百度问一问官网
  • 网站开发需求规格说明书seo网站推广方法
  • java网站开发优缺点免费无代码开发平台
  • 中国石化工程建设公司网站百度站长工具抓取诊断
  • ps模板网武汉seo排名公司
  • 化学药品购买网站中文搜索引擎网站
  • 江门cms建站公众号软文素材
  • 广州优俊网站制作公司鹤壁网络推广哪家好