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

北京网站建设设计公司哪家好网站页面设计版权

北京网站建设设计公司哪家好,网站页面设计版权,京东网上商城手机,西南网架公司我们在spring中使用dubbox相当简单&#xff0c;只需要配置一下即可 1. dubbox的配置 1.1 提供方 所谓的提供方&#xff0c;在我们的开发中一般指的是服务层 <?xml version"1.0" encoding"UTF-8"?> <beans xmlns"http://www.springfram…

我们在spring中使用dubbox相当简单,只需要配置一下即可

1. dubbox的配置

1.1 提供方

所谓的提供方,在我们的开发中一般指的是服务层

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"xmlns:context="http://www.springframework.org/schema/context"xmlns:dubbo="http://code.alibabatech.com/schema/dubbo" xmlns:mvc="http://www.springframework.org/schema/mvc"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsdhttp://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsdhttp://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"><!-- 访问Dubbox所要占用的端口(自己要占用的端口) 该配置这里不可以省略,否则后面会出现端口占用的情况--><dubbo:protocol name="dubbo" port="20884"></dubbo:protocol><dubbo:application name="search-service"/>  <!-- 这里的端口是服务端提供的端口号,是服务器上注册中心提供的端口 --><dubbo:registry address="zookeeper://192.168.25.130:2181"/><dubbo:annotation package="com.search.service.impl" />  </beans>

1.2 消费方

所谓的消费方,在我们开发中一般指的是web层,也就是调用方

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p"xmlns:context="http://www.springframework.org/schema/context"xmlns:dubbo="http://code.alibabatech.com/schema/dubbo" xmlns:mvc="http://www.springframework.org/schema/mvc"xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsdhttp://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsdhttp://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsdhttp://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"><context:property-placeholder location="classpath:config/application.properties" /><mvc:annotation-driven><mvc:message-converters register-defaults="true"><bean class="com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter">  <property name="supportedMediaTypes" value="application/json"/><property name="features"><array><value>WriteMapNullValue</value><value>WriteDateUseDateFormat</value></array></property></bean></mvc:message-converters>  </mvc:annotation-driven><!-- 引用dubbo 服务 --><dubbo:application name="search-web" /><dubbo:registry address="zookeeper://192.168.25.130:2181"/><dubbo:annotation package="com.search.controller" />  	</beans>

注意:服务方与消费方的注册中心地址要一致

2. dubbox的开发

在提供方,不需要做额外的操作,我们关心的是在消费方也就是web层的调用方怎么能访问到注册中心的服务,用dubbox提供的注解@Reference就可以。

例如;

@RestController
@RequestMapping("/itemsearch")
public class ItemSearchController {@Referenceprivate ItemSearchService itemSearchService;@RequestMapping("/search")public Map<String, Object> search(@RequestBody Map searchMap ){return itemSearchService.search(searchMap);}}

通过@Reference注解可以实现远程注入,在web层我们就可以调用该接口的方法了。

3. dubbox的超时配置

        我们在进行dubbox的开发的时候,经常会遇到dubbox的timeout的错误,这个错误的原因是dubbox默认连接时间是1秒钟,当我们的连接时间超过了这个时间的时候就会报超时错误了,所以我们可以给dubbox配置一个超时时间。

配置的方式有两种,一种是在提供方配置,例如;

注意:这里的service注解的包不是spring的是dubbox的com.alibaba.dubbo.config.annotation.Service; 

另一种是在消费方配置,例如:

当然,通常情况下,我们都是在提供方配置超时时间。 但是,我们要是两边都配置了超时时间,而且时间还不一样的时候,这个超时时间按照消费方配置的为准,也就是dubbox的超时时间优先读取消费方的超时时间。

 

http://www.yayakq.cn/news/494619/

相关文章:

  • 联通公司做网站吗百度收录提交
  • 深圳快速网站制作哪家快怎么做各大视频网站的会员代理
  • qq钓鱼网站在线生成器网站制作方案垂直领域获客
  • 网站建设品牌公司企业建立网站的必要性在于
  • 建设游戏运营网站开展工作总结企业宣传海报设计制作
  • 网站公司设计公司360免费建站方法
  • 自建购物网站建网站建设公司
  • 三合一网站搭建价格网站怎么做中英文交互
  • 如何建设公司门户网站免费网站空间怎么办
  • 网站后台乱码网站设计与建设实训
  • 网站视频与服务器的关系建设网站过水
  • 长沙长沙h5网站建设深圳龙华租房
  • 精准客户电话号码资源企业网站设计与优化
  • 广丰区建设局网站网站开发计划书模板
  • 湛江免费模板建站小红书推广引流软件
  • 微网站建设正规公司企业查查app下载
  • 微信淘宝购物券网站是怎么做的集约化网站群建设情况
  • 物流官网网站百度网址大全址大全
  • 网站首页的功能顺德网站建设jinqiye
  • 同城分类信息网站建设东莞模板网页制作
  • 个人建站如何赚钱wordpress备份 ftp
  • 余姚什么网站做装修比较好仿cnzz 网站 源码
  • 成都网站制作服务wordpress video.js
  • 网站制作公司费用邳州做网站pzwode
  • NET网站开发工程师网站招聘免费网站软件下载安装
  • 网站内容与模板设计网页设计流程25
  • 用别的域名给网站做竞价苏州网站建设联系电话
  • 山西省建设厅官方网站wordpress官方源文件结构
  • 网站授权协议东莞东城招聘网最新招聘
  • 企业网站建设457216336wordpress meta seo