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

广州网站建设小程序开发wordpress4.4.7漏洞

广州网站建设小程序开发,wordpress4.4.7漏洞,网页设计与制作张苏中素材,商业网站的域名代码Nacos 作为 Dubbo 生态系统中重要的注册中心实现#xff0c;本文将会介绍如何进行 Dubbo 对接 Nacos 注册中心的工作。 预备工作 请确保后台已经启动 Nacos 服务 快速上手 Dubbo 融合 Nacos 成为注册中心的操作步骤非常简单#xff0c;大致步骤可分为“增加 Maven 依赖”…Nacos 作为 Dubbo 生态系统中重要的注册中心实现本文将会介绍如何进行 Dubbo 对接 Nacos 注册中心的工作。 预备工作 请确保后台已经启动 Nacos 服务 快速上手 Dubbo 融合 Nacos 成为注册中心的操作步骤非常简单大致步骤可分为“增加 Maven 依赖”以及“配置注册中心“。 增加 Maven 依赖 只需要依赖Dubbo客户端即可关于推荐的使用版本请参考Dubbo官方文档或者咨询Dubbo开发人员 dependencies...dependencygroupIdcom.alibaba/groupIdartifactIddubbo/artifactIdversion3.0.5/version/dependency!-- Dubbo Nacos registry dependency --dependencygroupIdcom.alibaba/groupIdartifactIddubbo-registry-nacos/artifactIdversion3.0.5/version/dependency!-- Alibaba Spring Context extension --dependencygroupIdcom.alibaba.spring/groupIdartifactIdspring-context-support/artifactIdversion1.0.11/version/dependency.../dependencies配置注册中心 假设您 Dubbo 应用使用 Spring Framework 装配将有两种配置方法可选分别为Dubbo Spring 外部化配置以及 Spring XML 配置文件以及笔者强烈推荐前者。 Dubbo Spring 外部化配置 Dubbo Spring 外部化配置是由 Dubbo 2.5.8 引入的新特性可通过 Spring Environment 属性自动地生成并绑定 Dubbo 配置 Bean实现配置简化并且降低微服务开发门槛。 假设您 Dubbo 应用的使用 Nacos 作为注册中心并且其服务器 IP 地址为10.20.153.10同时该注册地址作为 Dubbo 外部化配置属性存储在 dubbo-config.properties 文件如下所示 ## application dubbo.application.name your-dubbo-application## Nacos registry address dubbo.registry.address nacos://10.20.153.10:8848 ##如果要使用自己创建的命名空间可以使用下面2种方式 #dubbo.registry.address nacos://10.20.153.10:8848?namespace5cbb70a5-xxx-xxx-xxx-d43479ae0932 #dubbo.registry.parameters.namespace5cbb70a5-xxx-xxx-xxx-d43479ae0932 ...随后重启您的 Dubbo 应用Dubbo 的服务提供和消费信息在 Nacos 控制台中可以显示 如图所示服务名前缀为 providers: 的信息为服务提供者的元信息consumers: 则代表服务消费者的元信息。点击“详情”可查看服务状态详情 如果您正在使用 Spring XML 配置文件装配 Dubbo 注册中心的话请参考下一节。 Spring XML 配置文件 同样假设您 Dubbo 应用的使用 Nacos 作为注册中心并且其服务器 IP 地址为10.20.153.10并且装配 Spring Bean 在 XML 文件中如下所示 ?xml version1.0 encodingUTF-8? beans xmlnshttp://www.springframework.org/schema/beansxmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexmlns:dubbohttp://dubbo.apache.org/schema/dubboxsi:schemaLocationhttp://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd!-- 提供方应用信息用于计算依赖关系 --dubbo:application namedubbo-provider-xml-demo /!-- 使用 Nacos 注册中心 --dubbo:registry addressnacos://10.20.153.10:8848 /!-- 如果要使用自己创建的命名空间可以使用下面配置 --!-- dubbo:registry addressnacos://10.20.153.10:8848?namespace5cbb70a5-xxx-xxx-xxx-d43479ae0932 / --... /beans重启 Dubbo 应用后您同样也能发现服务提供方和消费方的注册元信息呈现在 Nacos 控制台中 您是否觉得配置或切换 Nacos 注册中心超级 Easy 呢如果您仍旧意犹未尽或者不甚明白的话可参考以下完整的示例。 完整示例 以上图片中的元数据源于 Dubbo Spring 注解驱动示例以及 Dubbo Spring XML 配置驱动示例下面将分别介绍两者您可以选择自己偏好的编程模型。在正式讨论之前先来介绍两者的预备工作因为它们皆依赖 Java 服务接口和实现。同时请确保本地127.0.0.1环境已启动 Nacos 服务。 示例接口与实现 完整代码归档位置 https://github.com/nacos-group/nacos-examples/tree/master/nacos-dubbo-example 首先定义示例接口如下所示 package com.alibaba.nacos.example.dubbo.service;public interface DemoService {String sayName(String name); }提供以上接口的实现类 package com.alibaba.nacos.example.dubbo.service;import com.alibaba.dubbo.config.annotation.Service; import com.alibaba.dubbo.rpc.RpcContext; import org.springframework.beans.factory.annotation.Value;/*** Default {link DemoService}* https://nacos.io/zh-cn/docs/use-nacos-with-dubbo.html* since 2.6.5*/ Service(version ${demo.service.version}) public class DefaultService implements DemoService {Value(${demo.service.name})private String serviceName;public String sayName(String name) {RpcContext rpcContext RpcContext.getContext();return String.format(Service [name :%s , port : %d] %s(\%s\) : Hello,%s,serviceName,rpcContext.getLocalPort(),rpcContext.getMethodName(),name,name);} }接口与实现准备妥当后下面将采用注解驱动和 XML 配置驱动各自实现。 Spring 注解驱动示例 Dubbo 2.5.7 重构了 Spring 注解驱动的编程模型。 服务提供方注解驱动实现 定义 Dubbo 提供方外部化配置属性源 - provider-config.properties ## application dubbo.application.name dubbo-provider-demo## Nacos registry address dubbo.registry.address nacos://127.0.0.1:8848 ##如果要使用自己创建的命名空间可以使用下面2种方式 #dubbo.registry.address nacos://127.0.0.1:8848?namespace5cbb70a5-xxx-xxx-xxx-d43479ae0932 #dubbo.registry.parameters.namespace5cbb70a5-xxx-xxx-xxx-d43479ae0932## Dubbo Protocol dubbo.protocol.name dubbo dubbo.protocol.port -1# Provider Service version demo.service.version1.0.0 demo.service.name demoServicedubbo.application.qosEnablefalse 实现服务提供方引导类 - DemoServiceProviderBootstrap package com.alibaba.nacos.example.dubbo.provider;import com.alibaba.nacos.example.dubbo.service.DemoService; import org.apache.dubbo.config.spring.context.annotation.EnableDubbo; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.PropertySource; import java.io.IOException;/*** {link DemoService} provider demo* https://nacos.io/zh-cn/docs/use-nacos-with-dubbo.html*/ EnableDubbo(scanBasePackages com.alibaba.nacos.example.dubbo.service) PropertySource(value classpath:/provider-config.properties) public class DemoServiceProviderBootstrap {public static void main(String[] args) throws IOException {AnnotationConfigApplicationContext context new AnnotationConfigApplicationContext();context.register(DemoServiceProviderBootstrap.class);context.refresh();System.out.println(DemoService provider is starting...);System.in.read();} } 其中注解 EnableDubbo 激活 Dubbo 注解驱动以及外部化配置其 scanBasePackages 属性扫描指定 Java 包将所有标注 Service 的服务接口实现类暴露为 Spring Bean随即被导出 Dubbo 服务。 PropertySource 是 Spring Framework 3.1 引入的标准导入属性配置资源注解它将为 Dubbo 提供外部化配置。 服务消费方注解驱动实现 定义 Dubbo 消费方外部化配置属性源 - consumer-config.properties ## Dubbo Application info dubbo.application.name dubbo-consumer-demo## Nacos registry address dubbo.registry.address nacos://127.0.0.1:8848 ##如果要使用自己创建的命名空间可以使用下面2种方式 #dubbo.registry.address nacos://127.0.0.1:8848?namespace5cbb70a5-xxx-xxx-xxx-d43479ae0932 #dubbo.registry.parameters.namespace5cbb70a5-xxx-xxx-xxx-d43479ae0932# Reference version demo.service.version 1.0.0dubbo.application.qosEnablefalse同样地dubbo.registry.address 属性指向 Nacos 注册中心其他 Dubbo 服务相关的元信息通过 Nacos 注册中心获取。 实现服务消费方引导类 - DemoServiceConsumerBootstrap package com.alibaba.nacos.example.dubbo.consumer;import com.alibaba.nacos.example.dubbo.service.DemoService; import org.apache.dubbo.config.spring.context.annotation.EnableDubbo; import org.apache.dubbo.config.annotation.DubboReference; import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.PropertySource; import javax.annotation.PostConstruct; import java.io.IOException;/*** {link DemoService} consumer demo* https://nacos.io/zh-cn/docs/use-nacos-with-dubbo.html*/ EnableDubbo PropertySource(value classpath:/consumer-config.properties) public class DemoServiceConsumerBootstrap {DubboReference(version ${demo.service.version})private DemoService demoService;PostConstructpublic void init() {for (int i 0; i 10; i) {System.out.println(demoService.sayName(Nacos));}}public static void main(String[] args) throws IOException {AnnotationConfigApplicationContext context new AnnotationConfigApplicationContext();context.register(DemoServiceConsumerBootstrap.class);context.refresh();context.close();} } 同样地EnableDubbo 注解激活 Dubbo 注解驱动和外部化配置不过当前属于服务消费者无需指定 Java 包名扫描标注 Service 的服务实现。 Reference 是 Dubbo 远程服务的依赖注入注解需要服务提供方和消费端约定接口interface、版本version以及分组group信息。在当前服务消费示例中DemoService 的服务版本来源于属性配置文件 consumer-config.properties。 PostConstruct 部分代码则说明当 DemoServiceConsumerBootstrap Bean 初始化时执行十次 Dubbo 远程方法调用。 运行注解驱动示例 在本地启动两次 DemoServiceProviderBootstrap注册中心将出现两个健康服务 再运行 DemoServiceConsumerBootstrap运行结果如下 Service [name :demoService , port : 20880] sayName(Nacos) : Hello,Nacos Service [name :demoService , port : 20880] sayName(Nacos) : Hello,Nacos Service [name :demoService , port : 20880] sayName(Nacos) : Hello,Nacos Service [name :demoService , port : 20880] sayName(Nacos) : Hello,Nacos Service [name :demoService , port : 20880] sayName(Nacos) : Hello,Nacos Service [name :demoService , port : 20880] sayName(Nacos) : Hello,Nacos Service [name :demoService , port : 20880] sayName(Nacos) : Hello,Nacos Service [name :demoService , port : 20880] sayName(Nacos) : Hello,Nacos Service [name :demoService , port : 20880] sayName(Nacos) : Hello,Nacos Service [name :demoService , port : 20880] sayName(Nacos) : Hello,Nacos运行无误并且服务消费方使用了负载均衡策略将十次 RPC 调用平均分摊到两个 Dubbo 服务提供方实例中。 Spring XML 配置驱动示例 Spring XML 配置驱动是传统 Spring 装配组件的编程模型。 服务提供方 XML 配置驱动 定义服务提供方 XML 上下文配置文件 - /META-INF/spring/dubbo-provider-context.xml ?xml version1.0 encodingUTF-8? beans xmlnshttp://www.springframework.org/schema/beansxmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexmlns:dubbohttp://dubbo.apache.org/schema/dubboxsi:schemaLocationhttp://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd!-- 提供方应用信息用于计算依赖关系 --dubbo:application namedubbo-provider-xml-demo/!-- 使用 Nacos 注册中心 --dubbo:registry addressnacos://127.0.0.1:8848/!-- 如果要使用自己创建的命名空间可以使用下面配置 --!-- dubbo:registry addressnacos://127.0.0.1:8848?namespace5cbb70a5-xxx-xxx-xxx-d43479ae0932 / --!-- 用dubbo协议在随机端口暴露服务 --dubbo:protocol namedubbo port-1/!-- 声明需要暴露的服务接口 --dubbo:service interfacecom.alibaba.nacos.example.dubbo.service.DemoService refdemoService version2.0.0/!-- 和本地bean一样实现服务 --bean iddemoService classcom.alibaba.nacos.example.dubbo.service.DefaultService/ /beans实现服务提供方引导类 - DemoServiceProviderXmlBootstrap package com.alibaba.nacos.example.dubbo.provider;import com.alibaba.dubbo.demo.service.DemoService;import org.springframework.context.support.ClassPathXmlApplicationContext;import java.io.IOException;/*** {link DemoService} provider demo XML bootstrap*/ public class DemoServiceProviderXmlBootstrap {public static void main(String[] args) throws IOException {ClassPathXmlApplicationContext context new ClassPathXmlApplicationContext();context.setConfigLocation(/META-INF/spring/dubbo-provider-context.xml);context.refresh();System.out.println(DemoService provider (XML) is starting...);System.in.read();} }服务消费方 XML 配置驱动 定义服务消费方 XML 上下文配置文件 - /META-INF/spring/dubbo-consumer-context.xml ?xml version1.0 encodingUTF-8? beans xmlnshttp://www.springframework.org/schema/beansxmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexmlns:dubbohttp://dubbo.apache.org/schema/dubboxsi:schemaLocationhttp://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd!-- 提供方应用信息用于计算依赖关系 --dubbo:application namedubbo-consumer-xml-demo/!-- 使用 Nacos 注册中心 --dubbo:registry addressnacos://127.0.0.1:8848/!-- 如果要使用自己创建的命名空间可以使用下面配置 --!-- dubbo:registry addressnacos://127.0.0.1:8848?namespace5cbb70a5-xxx-xxx-xxx-d43479ae0932 / --!-- 引用服务接口 --dubbo:reference iddemoService interfacecom.alibaba.nacos.example.dubbo.service.DemoService version2.0.0//beans实现服务消费方引导类 - DemoServiceConsumerXmlBootstrap package com.alibaba.nacos.example.dubbo.consumer;import com.alibaba.dubbo.demo.service.DemoService;import org.springframework.context.support.ClassPathXmlApplicationContext;import java.io.IOException;/*** {link DemoService} consumer demo XML bootstrap*/ public class DemoServiceConsumerXmlBootstrap {public static void main(String[] args) throws IOException {ClassPathXmlApplicationContext context new ClassPathXmlApplicationContext();context.setConfigLocation(/META-INF/spring/dubbo-consumer-context.xml);context.refresh();System.out.println(DemoService consumer (XML) is starting...);DemoService demoService context.getBean(demoService, DemoService.class);for (int i 0; i 10; i) {System.out.println(demoService.sayName(Nacos));}context.close();} }运行 XML 配置驱动示例 同样地先启动两个 DemoServiceProviderXmlBootstrap 引导类观察 Nacos 注册中心服务提供者变化 XML 配置驱动的服务版本为 2.0.0因此注册服务无误。 再运行服务消费者引导类 DemoServiceConsumerXmlBootstrap观察控制台输出内容 Service [name :demoService , port : 20880] sayName(Nacos) : Hello,Nacos Service [name :demoService , port : 20880] sayName(Nacos) : Hello,Nacos Service [name :demoService , port : 20880] sayName(Nacos) : Hello,Nacos Service [name :demoService , port : 20880] sayName(Nacos) : Hello,Nacos Service [name :demoService , port : 20880] sayName(Nacos) : Hello,Nacos Service [name :demoService , port : 20880] sayName(Nacos) : Hello,Nacos Service [name :demoService , port : 20880] sayName(Nacos) : Hello,Nacos Service [name :demoService , port : 20880] sayName(Nacos) : Hello,Nacos Service [name :demoService , port : 20880] sayName(Nacos) : Hello,Nacos Service [name :demoService , port : 20880] sayName(Nacos) : Hello,Nacos结果同样运行和负载均衡正常不过由于当前示例尚未添加属性 demo.service.name 的缘故因此“name”部分信息输出为 null。
http://www.zqtcl.cn/news/380959/

相关文章:

  • 网站制作新报价橄榄树网站建设
  • 网站建设及服务合同小程序代码教程
  • 晋城网站建设公司淘宝店铺网站建设
  • 赣州网站建设流程上海重大新闻
  • html网站架设ui设计用的软件有哪些
  • 有没有做培养基的网站58同城淄博网站建设
  • 承德做网站的公司专业平台建设网站关了吗
  • 自己做网站的成本要哪些东西wordpress resize
  • 网站建设总体流程wordpress 浮窗音乐
  • 福州网站建设公司哪个网站可以做前端项目
  • 十二冶金建设集团有限公司网站wordpress安装在哪里
  • 怎么做网站源码wordpress的rss
  • wordpress能不能做企业网站软件技术和计算机网络技术哪个好
  • 甘肃省住房和城乡建设部网站首页ip怎么做网站
  • 怎么开一家网站开发公司百度推广一年大概需要多少钱
  • 小破站下载h5企业模板网站
  • 服务器怎么设置ip做网站凌云seo博客
  • 莱芜四大金刚是谁啊镇江网站优化推广
  • 上海门户网站开发企业号码查询系统
  • 西安做网站设计的公司golang 网站开发 教程
  • 做网站哪些公司专业做app软件开发公司
  • 蒙特网站建设湖北省建设厅网站上岗证查询
  • 宁波网站建设 联系哪家电子商务网站建设过程范文
  • 南宁商城网站建设网站建设的需求文档
  • dedeampz 部署wordpress 网站访问慢如何评价网站是否做的好处
  • 怎样建设个人影视网站设计学专业
  • 没有公司 接单做网站网站建设加盟合作
  • 如何将域名和网站绑定做网站找投资人
  • 网站开发 平台WordPress首页可见
  • 沧州做网站费用打开上海发布