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

曲阜网站建设价格今晚赛事比分预测

曲阜网站建设价格,今晚赛事比分预测,专门做批发的网站吗,湖南网络工程职业学院目录1、dubbo简介2、dubbo解决了什么问题3、环境准备4、项目搭建5、总结springboot整合feign可参考我另外一篇文章SpringBoot集成Feign 1、dubbo简介 Apache Dubbo 最初在 2008 年由 Alibaba 捐献开源,很快成为了国内开源服务框架选型的事实标准框架 ,…

目录

  • 1、dubbo简介
  • 2、dubbo解决了什么问题
  • 3、环境准备
  • 4、项目搭建
  • 5、总结

springboot整合feign可参考我另外一篇文章SpringBoot集成Feign

1、dubbo简介

Apache Dubbo 最初在 2008 年由 Alibaba 捐献开源,很快成为了国内开源服务框架选型的事实标准框架 ,得到了各行各业的广泛应用。在 2017 年,Dubbo 正式捐献到 Apache 软件基金会并成为 Apache 顶级项目,目前 Dubbo3 已经是一站式的微服务解决方案。可以看到自 SpringCloud Alibaba 2021.0.1.0 起,Dubbo已被移除SpringCloud Alibaba 。目前基本都是使用org.apache.dubbo,而com.alibaba.dubbo已被弃用。
在这里插入图片描述

2、dubbo解决了什么问题

分类dubbo的特性
高性能RPC调用(主)提供高性能的基于代理的远程调用能力,服务以接口为粒度,为开发者屏蔽远程调用底层细节
服务自动注册与发现支持多种注册中心服务,服务实例上下线实时感知
运行期流量调度内置条件、脚本等路由策略,通过配置不同的路由规则,轻松实现灰度发布、同机房优先等功能
智能负载均衡内置多种负载均衡策略,智能感知下游节点健康状况,显著减少调用延迟,提高系统吞吐量
高度可扩展能力遵循微内核+插件的设计思想,所有核心能力如Protocol、Transport、Serialization被设计为扩展点,平等对待内置实现和第三方实现
可视化的服务治理与运维提供丰富服务治理、运维工具:随时查询服务元数据、服务监控状态以及调用统计,实时下发路由策略,调整配置参数

3、环境准备

系统:windows
JDK:1.8
Maven:3.8.1
Nacos:2.2.0 (下载和使用介绍:【Nacos】SpringBoot集成Nacos)

项目下载模板地址:https://github.com/shengwanping/SpringBoot-dubbo-demo.git

4、项目搭建

1、首先创建一个基于Maven的工程
在这里插入图片描述

2、然后创建三个子项目:springboot-dubbo-provider、springboot-dubbo-interface、springboot-dubbo-consumer,如下

在这里插入图片描述
在这里插入图片描述

3、每个子项目分别创建如下三个目录:org.dubbo.consumer; org.dubbo; org.dubbo.provider
在这里插入图片描述

4、父项目中添加Maven依赖
在这里插入图片描述

<!--dependencyManagement 依赖管理,子项目不会继承父依赖,需要重新声明--><dependencyManagement><dependencies><!-- spring-boot依赖--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-dependencies</artifactId><version>2.3.12.RELEASE</version><type>pom</type><scope>import</scope></dependency><!-- spring-cloud alibaba依赖--><dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-alibaba-dependencies</artifactId><version>2.2.7.RELEASE</version><type>pom</type><scope>import</scope></dependency></dependencies></dependencyManagement><!--com.alibaba.cloud 2.2.7版本有个坑,需要把spring-context-support升到1.0.11才能启动项目--><dependencies><dependency><groupId>com.alibaba.spring</groupId><artifactId>spring-context-support</artifactId><version>1.0.11</version></dependency></dependencies>

5、然后在 springboot-dubbo-consumer 和 springboot-dubbo-provider 两个模块 pom.xml 中进行具体依赖的配置
在这里插入图片描述

<dependencies><!--引入 springboot-dubbo-interface 接口服务--><dependency><groupId>org.example</groupId><artifactId>springboot-dubbo-interface</artifactId><version>1.0-SNAPSHOT</version></dependency><!-- springboot 依赖--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><!--  nacos 服务的注册发现     --><dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId></dependency><!--  nacos  配置中心做依赖管理    --><dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-dubbo</artifactId></dependency><!-- dubbo-apache --><dependency><groupId>org.apache.dubbo</groupId><artifactId>dubbo-spring-boot-starter</artifactId><version>2.7.8</version></dependency></dependencies>

6、定义服务接口

在这里插入图片描述

package org.dubbo;public interface DemoService {String sayHello(String name);
}

7、配置服务端yml文件

在这里插入图片描述

server:port: 8010spring:# 应用名称(nacos会将改名称作为服务名称)application:name: springboot-dubbo-providercloud:nacos:server-addr: localhost:8848# 注册中心discovery:namespace: public #命名空间,如prod,dev,默认public# 配置中心config:server-addr: localhost:8848dubbo:protocol:name: dubboport: -1registry:address: nacos://localhost:8848

8、配置消费端yml文件

在这里插入图片描述

server:port: 8011spring:# 应用名称(nacos会将改名称作为服务名称)application:name: springboot-dubbo-consumercloud:nacos:server-addr: localhost:8848# 注册中心discovery:namespace: public #命名空间,如prod,dev,默认public# 配置中心config:server-addr: localhost:8848dubbo:protocol:name: dubboport: -1registry:address: nacos://localhost:8848

9、定义服务端的实现 和 服务端启动类
在这里插入图片描述
实现类:

package org.dubbo.provider;import org.apache.dubbo.config.annotation.DubboService;
import org.dubbo.DemoService;@DubboService
public class DemoServiceImpl implements DemoService {@Overridepublic String sayHello(String name) {return "Hello " + name;}
}

启动类:

package org.dubbo.provider;import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@EnableDubbo
@SpringBootApplication
public class ProviderApplication {public static void main(String[] args) {SpringApplication.run(ProviderApplication.class, args);}
}

10、定义消费端 启动类和调用类
在这里插入图片描述
启动类:

package org.dubbo.consumer;import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;@SpringBootApplication
@EnableDubbo
public class ConsumerApplication {public static void main(String[] args) {SpringApplication.run(ConsumerApplication.class, args);}
}

调用类:

package org.dubbo.consumer;import java.util.Date;import org.apache.dubbo.config.annotation.DubboReference;
import org.dubbo.DemoService;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;@Component
public class Task implements CommandLineRunner {@DubboReferenceprivate DemoService demoService;@Overridepublic void run(String... args) throws Exception {String result = demoService.sayHello("world");System.out.println("Receive result ======> " + result);new Thread(()-> {while (true) {try {Thread.sleep(1000);System.out.println(new Date() + " Receive result ======> " + demoService.sayHello("world"));} catch (InterruptedException e) {e.printStackTrace();Thread.currentThread().interrupt();}}}).start();}
}

11、分别先后启动 服务启动类 和 消费启动类,当消费启动类控制台看到如下信息则说明成功了。

在这里插入图片描述

还可在nacos中看到注入的两个服务
在这里插入图片描述

5、总结

简单理解在微服务中使用Dubbo实现RPC远程接口调用,只需要满足如下几个条件:

1、导入org.apache.dubbo maven依赖。
2、配置基于dubbo的yml配置文件
3、在启动类加上@EnableDubbo注解
4、被调用接口实现类使用@DubboService注解
5、调用接口时使用@DubboReference注解

参考地址:
https://cn.dubbo.apache.org/zh-cn/overview/what/overview/
https://spring.io/projects/spring-cloud
https://blog.csdn.net/x734400146/article/details/108087926


文章转载自:
http://dinncoethnography.stkw.cn
http://dinncodraughtsman.stkw.cn
http://dinncocd.stkw.cn
http://dinncopipless.stkw.cn
http://dinncobedroll.stkw.cn
http://dinncokeeve.stkw.cn
http://dinncoaerometry.stkw.cn
http://dinncouranide.stkw.cn
http://dinncostylist.stkw.cn
http://dinncorejection.stkw.cn
http://dinncoautogenesis.stkw.cn
http://dinncopastellist.stkw.cn
http://dinncoorthopedics.stkw.cn
http://dinncoviewy.stkw.cn
http://dinncooblast.stkw.cn
http://dinncohanap.stkw.cn
http://dinncoskullfish.stkw.cn
http://dinncohizen.stkw.cn
http://dinncounbroke.stkw.cn
http://dinnconadir.stkw.cn
http://dinncoenteral.stkw.cn
http://dinncooligocarpous.stkw.cn
http://dinncogonadectomy.stkw.cn
http://dinncounprimed.stkw.cn
http://dinncodissentious.stkw.cn
http://dinncogroomsman.stkw.cn
http://dinncodekagram.stkw.cn
http://dinncoskyer.stkw.cn
http://dinncocomprisable.stkw.cn
http://dinncogoddess.stkw.cn
http://dinncopandh.stkw.cn
http://dinnconeglect.stkw.cn
http://dinncowastewater.stkw.cn
http://dinncomembranaceous.stkw.cn
http://dinncopycnogonid.stkw.cn
http://dinncocreationary.stkw.cn
http://dinncoarf.stkw.cn
http://dinncoblame.stkw.cn
http://dinncodoughface.stkw.cn
http://dinncohabsburg.stkw.cn
http://dinncomisalliance.stkw.cn
http://dinncounionist.stkw.cn
http://dinncojapheth.stkw.cn
http://dinncochorea.stkw.cn
http://dinncovacationist.stkw.cn
http://dinncodefecate.stkw.cn
http://dinncofetiferous.stkw.cn
http://dinncojestingly.stkw.cn
http://dinncoboar.stkw.cn
http://dinncorebaptize.stkw.cn
http://dinncoexude.stkw.cn
http://dinncolignicolous.stkw.cn
http://dinncoforky.stkw.cn
http://dinncovespertilionid.stkw.cn
http://dinncojejunectomy.stkw.cn
http://dinncocircumvolution.stkw.cn
http://dinncobung.stkw.cn
http://dinncobalneotherapy.stkw.cn
http://dinncomastigophoran.stkw.cn
http://dinncoroughwrought.stkw.cn
http://dinncounprimitive.stkw.cn
http://dinncoericeticolous.stkw.cn
http://dinncofatuity.stkw.cn
http://dinncospank.stkw.cn
http://dinncochlorohydrin.stkw.cn
http://dinncoechelon.stkw.cn
http://dinncocycad.stkw.cn
http://dinncoinfuriate.stkw.cn
http://dinncodefamation.stkw.cn
http://dinncorainspout.stkw.cn
http://dinncohospitality.stkw.cn
http://dinncosailflying.stkw.cn
http://dinncosomatotopical.stkw.cn
http://dinncoeverything.stkw.cn
http://dinncosyph.stkw.cn
http://dinncodysphagy.stkw.cn
http://dinncoopportunist.stkw.cn
http://dinncoflattie.stkw.cn
http://dinncohearted.stkw.cn
http://dinncohammam.stkw.cn
http://dinncohegemonism.stkw.cn
http://dinncoindicium.stkw.cn
http://dinncoclint.stkw.cn
http://dinncoaldermanry.stkw.cn
http://dinncocineangiography.stkw.cn
http://dinncoplebeianize.stkw.cn
http://dinncoshasta.stkw.cn
http://dinncocompuphone.stkw.cn
http://dinncomanicotti.stkw.cn
http://dinncotorticollis.stkw.cn
http://dinncojointing.stkw.cn
http://dinncodeucedly.stkw.cn
http://dinncoafterthought.stkw.cn
http://dinncodomineer.stkw.cn
http://dinncoscaphopod.stkw.cn
http://dinncojeep.stkw.cn
http://dinncostager.stkw.cn
http://dinncostrake.stkw.cn
http://dinncobridal.stkw.cn
http://dinncofrigidaria.stkw.cn
http://www.dinnco.com/news/88083.html

相关文章:

  • 网站防护找谁做长春头条新闻今天
  • 中国域名拍卖网宁德seo公司
  • 北京做erp报价的网站网页设计与网站建设教程
  • 微网站和h5有什么区别网络营销的50种方法
  • 漳州做网站seo案例
  • 网站小视频怎么做各大免费推广网站
  • 静态网站后台seo优化网站的手段
  • b2c电商网站建设内蒙古seo
  • 荆门网站建设公司360网站安全检测
  • 互联网保险的典型产品关键词优化上海
  • jsp做的零食店网站网页推广链接怎么做
  • 咸阳市建设局网站个人网站免费制作平台
  • 手机网站html模板今日小说排行榜
  • 如何做网站广告图片外贸营销网站建设介绍
  • 网站肯定被k精准营销的概念
  • 电商网站开发成本今日新闻头条新闻
  • 贵州做网站公司seo排名赚能赚钱吗
  • 海外网站免费建设seo技术中心
  • 北京软件开发培训机构长沙seo计费管理
  • redis 在网站开发中怎么用友情链接交换网站
  • 申请备案 关网站360排名检测
  • 做织带的网站百度关键词排名手机
  • 长春做公司网站上海单个关键词优化
  • 做h5的网站有哪些南宁哪里有seo推广厂家
  • 微信小程序做网站sem是什么意思的缩写
  • 宿州网站制作怎么自己做网址
  • 网站开发视频教程百度网盘自媒体论坛交流推荐
  • b2c典型电子商务平台有哪些网站关键词优化技巧
  • wordpress调用指定菜单网站seo检测工具
  • 南昌个人做网站推广公司主要做什么