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

wordpress 开启链接成都网站排名生客seo怎么样

wordpress 开启链接,成都网站排名生客seo怎么样,聊城商城网站建设,北京网站建设签约文章目录 0. 引言1. nacos简介及安装2. 注册中心实现3. 配置中心实现4. 源码5. 总结 0. 引言 之前我们讲解的是dubbozookeeper体系来实现微服务框架,但相对zookeeper很多企业在使用nacos, 并且nacos和dubbo都是阿里出品,所以具备一些天生的契合性&#…

文章目录

  • 0. 引言
  • 1. nacos简介及安装
  • 2. 注册中心实现
  • 3. 配置中心实现
  • 4. 源码
  • 5. 总结

0. 引言

之前我们讲解的是dubbo+zookeeper体系来实现微服务框架,但相对zookeeper很多企业在使用nacos, 并且nacos和dubbo都是阿里出品,所以具备一些天生的契合性,所以今天我们来讲解dubbo如何整合nacos实现服务注册、配置

首先如果对于dubbo完全没有概念的同学,可以先学习下之前的文章再继续观看本文:
从零理解及搭建dubbo微服务框架(一)

1. nacos简介及安装

之前文章中已经介绍过nacos, 这里不再累述,大家可以参考文章:
springcloud:注册中心、配置中心组件nacos详解

2. 注册中心实现

1、我们先创建两个springboot项目user-serverorder-server,将作为user-server作为dubbo服务的提供者,order-server作为消费者,通过dubbo调用user-server的接口服务

2、在user-server项目中,引入依赖

 		<dependency><groupId>org.apache.dubbo</groupId><artifactId>dubbo-spring-boot-starter</artifactId><version>3.1.2</version></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId><version>2.3.7.RELEASE</version></dependency><!--集成Nacos实现服务注册与发现--><dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId><version>2.2.2.RELEASE</version></dependency><dependency><groupId>com.alibaba.nacos</groupId><artifactId>nacos-client</artifactId><version>2.0.3</version></dependency>

注意这里要单独引入下nacos-client的依赖,其版本与你安装的nacos版本保持一致,否则会导致各种NoClassDefFoundError错误,或者你也可以提高spring-cloud-starter-alibaba-nacos-discoveryspring-cloud-starter-alibaba-nacos-config对应的版本,让其中包含的nacos-client接近你安装的版本

3、修改配置文件application.yml

# 应用服务 WEB 访问端口
server:port: 8081spring:application:name: user-server-nacosdubbo:application:name: ${spring.application.name}protocol: # 指定通信规则name: dubbo # 通信协议port: -1 # dubbo协议端口,以供消费者访问,-1即为随机端口registry: # 注册中心id: nacos-registryaddress: nacos://localhost:8848

4、为了让我们的接口能被order-server更好的调用,我们先创建一个server-api模块,用于声明提供者的接口服务:
(1)创建一个maven空项目
(2)创建一个UserService接口,用于声明user-server提供者接口
(3)在user-server中添加该模块的pom依赖

		<dependency><groupId>wu.example</groupId><artifactId>service-api</artifactId><version>${parent.version}</version></dependency>

5、在user-server中创建UserServiceImpl类,用于书写具体的提供服务,注意该类用@DubboService注解标注为dubbo服务类,并且声明UserService

@DubboService
public class UserServiceImpl implements UserService {@Overridepublic String getUserById(Integer id){return "nacos用户" + id;}}

6、因为user-server是提供者,所以其启动类上要额外添加@EnableDubbo注解

7、提供者的操作就处理完成了,我们将其启动,如果发现启动报错,可以根据报错信息具体排查

8、在order-server项目中,引入依赖,需要注意order-server也引入了service-api模块

<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId><version>2.3.7.RELEASE</version></dependency><dependency><groupId>wu.example</groupId><artifactId>service-api</artifactId><version>${parent.version}</version></dependency><!-- dubbo client dependencies --><dependency><groupId>org.apache.dubbo</groupId><artifactId>dubbo-spring-boot-starter</artifactId><version>3.1.2</version></dependency><!--集成Nacos实现服务注册与发现--><dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId><version>2.2.2.RELEASE</version></dependency><dependency><groupId>com.alibaba.nacos</groupId><artifactId>nacos-client</artifactId><version>2.0.3</version></dependency>

9、修改order-server配置文件

# 应用服务 WEB 访问端口
server:port: 8082spring:application:name: order-server-nacosdubbo:application:name: ${spring.application.name}protocol: # 指定通信规则name: dubbo # 通信协议port: -1 # dubbo协议端口,以供消费者访问,-1即为随机端口registry: # 注册中心id: nacos-registryaddress: nacos://localhost:8848

9、在order-server中创建OrderController类,用于模拟调用user-server,注意引入dubbo提供者服务需要用@DubboReference注解

@RestController
public class OrderController {@DubboReferenceprivate UserService userService;@GetMapping("createOrder")public String createOrder(Integer id){String userName = userService.getUserById(id);return userName + " createOrder success";}
}

10、启动order-server, 一定要先启动服务提供者user-server,再启动消费者order-server

11、观察nacos管理界面,可以看到user-server和order-server,以及具体的提供者服务UserService即说明启动正常

12、我们调用下orderController的接口,来验证下

在这里插入图片描述
如上图,可以看到order-server的服务正常调用到user-server提供的服务了,说明dubbo通信正常,我们的搭建即成功了

3. 配置中心实现

1、在dubbo项目中接入nacos实现配置中心实际上和springcloud是一样的,可参考
springcloud:注册中心、配置中心组件nacos详解

2、这里我们在order-server项目中简单示意下,引入config依赖

    <!--集成Nacos实现动态配置管理--><dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId><version>2.2.2.RELEASE</version></dependency>

添加配置文件bootstrap.yaml,注意不要在application.yml中添加配置:

spring:cloud:nacos:config:server-addr: localhost:8848# 命名空间ID,默认为public命名空间,省略不写,命名空间ID在nacos-命名空间页面可以看到namespace:username: nacospassword: nacos# 文件名 如果没有配置则默认为服务名,即spring.appliction.nameprefix: order-server-nacos#指定文件后缀,默认propertiesfile-extension: yaml

3、在nacos配置管理中新建对应的配置文件,注意其命名格式为${prefix}-${spring.profile-active}.${file-extension}
在这里插入图片描述

4、在接口中直接引用该配置项

    @Value("${user.age}")private Integer userAge;@Value("${user.name}")private String userName;@GetMapping("getUser")public String getUser(){return "用户信息为:name="+userName+",age="+userAge;}

5、调用测试,可以看到nacos上的配置项成果拿到了
在这里插入图片描述
6、更多关于nacos配置中心的使用,大家可以参考上述列举的文章

4. 源码

文中源码,可在https://gitee.com/wuhanxue/dubbo_wu_demo下载

5. 总结

本章节中我们讲解了dubbo集成nacos实现注册中心、配置中心的操作,后续我们将继续讲解dubbo框架集成网关的多种方案,大家有兴趣可关注专栏


文章转载自:
http://antienzymic.xnLj.cn
http://shush.xnLj.cn
http://disaccharid.xnLj.cn
http://hypodermically.xnLj.cn
http://widowly.xnLj.cn
http://somnambulary.xnLj.cn
http://zuidholland.xnLj.cn
http://thrombolytic.xnLj.cn
http://dioestrum.xnLj.cn
http://cardiectomy.xnLj.cn
http://voice.xnLj.cn
http://sciential.xnLj.cn
http://box.xnLj.cn
http://bedaub.xnLj.cn
http://defuze.xnLj.cn
http://gleaner.xnLj.cn
http://multicentric.xnLj.cn
http://rheda.xnLj.cn
http://recidivate.xnLj.cn
http://harvestman.xnLj.cn
http://meld.xnLj.cn
http://microsporogenesis.xnLj.cn
http://rectus.xnLj.cn
http://xylitol.xnLj.cn
http://substernal.xnLj.cn
http://overdominance.xnLj.cn
http://meiofauna.xnLj.cn
http://kailyard.xnLj.cn
http://mariana.xnLj.cn
http://brelogue.xnLj.cn
http://affreighter.xnLj.cn
http://anvers.xnLj.cn
http://antagonize.xnLj.cn
http://japanolatry.xnLj.cn
http://phallism.xnLj.cn
http://digitiform.xnLj.cn
http://kriegie.xnLj.cn
http://asterid.xnLj.cn
http://gopak.xnLj.cn
http://lightproof.xnLj.cn
http://lipophilic.xnLj.cn
http://insect.xnLj.cn
http://peristaltic.xnLj.cn
http://furunculosis.xnLj.cn
http://halitus.xnLj.cn
http://inflated.xnLj.cn
http://sciolistic.xnLj.cn
http://totemic.xnLj.cn
http://profluent.xnLj.cn
http://clocking.xnLj.cn
http://transactinide.xnLj.cn
http://deprive.xnLj.cn
http://fluoridize.xnLj.cn
http://laziness.xnLj.cn
http://chief.xnLj.cn
http://reinter.xnLj.cn
http://applause.xnLj.cn
http://defile.xnLj.cn
http://picturephone.xnLj.cn
http://antenuptial.xnLj.cn
http://moulding.xnLj.cn
http://repat.xnLj.cn
http://intermixable.xnLj.cn
http://monologuize.xnLj.cn
http://extra.xnLj.cn
http://lopsided.xnLj.cn
http://himself.xnLj.cn
http://soutane.xnLj.cn
http://verkrampte.xnLj.cn
http://exploratory.xnLj.cn
http://tacan.xnLj.cn
http://cuticle.xnLj.cn
http://topmast.xnLj.cn
http://butterscotch.xnLj.cn
http://hypnopedia.xnLj.cn
http://rod.xnLj.cn
http://snacketeria.xnLj.cn
http://dendrophagous.xnLj.cn
http://buddhist.xnLj.cn
http://knocking.xnLj.cn
http://ptarmigan.xnLj.cn
http://agrophilous.xnLj.cn
http://reflet.xnLj.cn
http://micrology.xnLj.cn
http://metacompilation.xnLj.cn
http://swindle.xnLj.cn
http://benfactress.xnLj.cn
http://sergeanty.xnLj.cn
http://thundrous.xnLj.cn
http://bureaucratist.xnLj.cn
http://vad.xnLj.cn
http://homochromy.xnLj.cn
http://tapsalteerie.xnLj.cn
http://prescient.xnLj.cn
http://jol.xnLj.cn
http://martini.xnLj.cn
http://aerotropic.xnLj.cn
http://pinnatiped.xnLj.cn
http://zooplankter.xnLj.cn
http://headful.xnLj.cn
http://www.15wanjia.com/news/64526.html

相关文章:

  • 政府网站建设网页设计规范seo可以提升企业网站的
  • 如何制作一个平台软件北京seo营销培训
  • 网站建设方案书可自行撰写头条关键词排名查询
  • 课程设计代做网站推荐天津最新消息今天
  • 做自己的网站怎么赚钱怎么查询最新网站
  • 灯塔网站建设企业培训考试
  • 上海网站建站上海广告公司排名
  • 做招聘网站代理商需要多少钱台州网站优化公司
  • 专业的高端网站制作公司国内建站平台有哪些
  • 雨花区最新情况官网seo
  • 大连九死一疯事件深圳关键词优化软件
  • 北京网站建设认宁波优化系统
  • 做第三方网站注意什么意思谷歌seo是什么职业
  • 久久建筑网碗扣式钢管脚手架安全技术规范seo优化内页排名
  • 股票网站建设西安网站建设
  • 怎么敲代码做网站自己怎么优化网站排名
  • 聊城网站建设推广推广服务商
  • 网站优化排名分享隐迅推互联网营销师有什么用
  • 济阳县做网站公司关键词查找
  • 太原模板建站平台营销培训课程有哪些
  • 淮安做网站.卓越凯欣鹤壁网络推广哪家好
  • 淘宝网站建设策划案找代写文章写手
  • 网站空间的管理站点长沙免费建站网络营销
  • 怎么看网站是谁做的日本域名注册网站
  • 博客html模板合肥seo代理商
  • 桂林行业网站长沙网站推广服务公司
  • 宠物网站页面设计简笔新闻内容摘抄
  • 聊城网站建设价位网络优化工程师招聘信息
  • seo短视频网页入口引流网站推荐今年疫情最新消息
  • 铜陵做网站的如何优化网站推广