1、服务提供方的bubbo配置:

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:task="http://www.springframework.org/schema/task"
xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task-4.0.xsd
http://code.alibabatech.com/schema/dubbo
http://code.alibabatech.com/schema/dubbo/dubbo.xsd"> <!-- 配置Dubbo提供方 -->
<!-- 配置提供方的名称即服务名 -->
<dubbo:application name="babasport-service-product"/> <!-- 配置注册中心 -->
<!-- 配置集群的zookeeper机器,address中间用逗号隔开,端口号在zookeeper的config文件中查看;protocol:协议为zookeeper
<dubbo:registry address="192.168.1.1:2181,192.168.1.2:2182" protocol="zookeeper"/> -->
<dubbo:registry address="192.168.1.110:2181" protocol="zookeeper"/> <!-- 设置端口号(服务提供方的), 若不设置则默认是20880 -->
<dubbo:protocol port="20880" name="dubbo"/> <!-- 暴露的接口 -->
<dubbo:service interface="cn.itcast.core.service.TestTbService" ref="testTbService"/> </beans>

2、服务的消费方配置:

<?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:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:task="http://www.springframework.org/schema/task" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task-4.0.xsd
http://code.alibabatech.com/schema/dubbo
http://code.alibabatech.com/schema/dubbo/dubbo.xsd"> <!-- Dubbo的消费方,消费方的名称 -->
<dubbo:application name="babasport-console"/> <!-- 注册中心 -->
<dubbo:registry address="192.168.1.110:2181" protocol="zookeeper"/> <!-- 获取接口及实现类 -->
<dubbo:reference interface="cn.itcast.core.service.TestTbService" id="testTbService"/> </beans>

注意:

使用Dubbo传递参数,该参数需要实现序列化。

spring MVC中Dubbo的配置的更多相关文章

  1. spring mvc中拦截器配置mvc:interceptors

    其实在mvc:interceptors标签中,有两种类型的配置,一种直接配置一个bean(bean和ref归为一类),另一种还要配置上拦截的路径和排除的路径.直接配置的bean那就代表对所有的请求进行 ...

  2. spring mvc 中web.xml配置信息解释

    在项目中总会遇到一些关于加载的优先级问题,近期也同样遇到过类似的,所以自己查找资料总结了下,下面有些是转载其他人的,毕竟人家写的不错,自己也就不重复造轮子了,只是略加点了自己的修饰. 首先可以肯定的是 ...

  3. spring mvc 中 controller 路径配置

    下图中,由于红色部分(value="/")的存在,导致 host:port/项目/dimlist 无法被映射到dimList方法,解决办法是将其去掉. package cn.bgo ...

  4. spring mvc中使用freemark的一点心得

    参考文档: FreeMarker标签与使用 连接http://blog.csdn.net/nengyu/article/details/6829244 freemarker学习笔记--指令参考: ht ...

  5. Spring MVC中处理静态资源的多种方法

    处理静态资源,我想这可能是框架搭建完成之后Web开发的”头等大事“了. 因为一个网站的显示肯定会依赖各种资源:脚本.图片等,那么问题来了,如何在页面中请求这些静态资源呢? 还记得Spring MVC中 ...

  6. Spring MVC 中的基于注解的 Controller【转】

    原文地址:http://my.oschina.net/abian/blog/128028 终于来到了基于注解的 Spring MVC 了.之前我们所讲到的 handler,需要根据 url 并通过 H ...

  7. spring mvc中的文件上传

    使用commons-fileupload上传文件所需要的架包有:commons-fileupload 和common-io两个架包支持,可以到Apache官网下砸. 在配置文件spring-mvc.x ...

  8. Spring MVC中基于注解的 Controller

         终于来到了基于注解的 Spring MVC 了.之前我们所讲到的 handler,需要根据 url 并通过 HandlerMapping 来映射出相应的 handler 并调用相应的方法以响 ...

  9. Spring MVC 中的 forward 和 redirect

    Spring MVC 中,我们在返回逻辑视图时,框架会通过 viewResolver 来解析得到具体的 View,然后向浏览器渲染.假设逻辑视图名为 hello,通过配置,我们配置某个 ViewRes ...

随机推荐

  1. ubuntu16.04获取root权限并用root用户登录

    写在全面:如果根据以下教程涉及到只读文件需要更改文件权限才能需修改文件内容,参考我的另一篇博客:https://www.cnblogs.com/masbay/p/10744900.html中的第2条. ...

  2. Struts 框架

    struts简介 Struts是Apache软件基金会(ASF)赞助的一个开源项目.它最初是jakarta项目中的一个子项目,并在2004年3月成为ASF的顶级项目.它通过采用JavaServlet/ ...

  3. kotlin函数api

    原 Kotlin学习(4)Lambda 2017年09月26日 21:00:03 gwt0425 阅读数:551   记住Lambda的本质,还是一个对象.和JS,Python等不同的是,Kotlin ...

  4. tomcat 下配置 可 调试

    set JAVA_OPTS=-Djute.maxbuffer=2048000 set console_log=true 起始行配置 rem Ensure that any user defined C ...

  5. php分割最后一个逗号后面的字符

    $str = 'a/b/c/d/e/f'; echo preg_replace('/.*\//','',$str);     echo preg_replace('/.*,/','',$str);最后 ...

  6. sql-mybatis-多表查询不查的字段一定不要查

    在多表联查的时候,这时用的是左外联(即如果右边的没有就查出左边的表) 如果右边的没有,那么在Navicat中查询出如下图 而在mybatis中运用同样的查询语句时,查询出来字段的也是这样 这时如果左表 ...

  7. webpack 学习

    ·1.https://www.2cto.com/kf/201711/696035.html 2. http://blog.csdn.net/x550392236/article/details/784 ...

  8. 1.3.1、CDH 搭建Hadoop在安装之前(端口---Cloudera Manager和Cloudera Navigator使用的端口)

    下图概述了Cloudera Manager,Cloudera Navigator和Cloudera Management Service角色使用的一些端口: Cloudera Manager和Clou ...

  9. cdh 安装系列2--cdh manager product 安装

    前期准备工作: 准备三台centos7 地址分别为 192.168.20.163:192.168.20.162:192.168.20.161 用163这台机器链接外网,并安装manager以及mana ...

  10. pngencoder图像转换jar

    PngEncoder - convert a Java Image to PNGPngEncoderB - convert a Java BufferedImage to PNG Written by ...