dobbo配置

大家dubbo服务项目


1. 第一步:web.xm 配置dubbo监听器

<?xml version="1.0"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
        "http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>classpath*:spring/service-root.xml</param-value>
    </context-param>

    <!--this listener must be defined before the spring listener-->
    <listener>
        <listener-class>com.alibaba.dubbo.remoting.http.servlet.BootstrapListener</listener-class>
    </listener>

    <listener>
        <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>

    <servlet>
        <servlet-name>dispatcher</servlet-name>
        <servlet-class>com.alibaba.dubbo.remoting.http.servlet.DispatcherServlet</servlet-class>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>dispatcher</servlet-name>
        <url-pattern>/*</url-pattern>
    </servlet-mapping>
</web-app>

dubbo 配置文件

<?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:dubbo="http://code.alibabatech.com/schema/dubbo"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">

    <!--声明dubbo服务基本信息-->
    <dubbo:application name="dobboProjectName" owner="zhengyong" organization="dubbox"/>
    <dubbo:registry protocol="zookeeper"  group="${zookeeper.root}"  address="${zookeeper.address}" timeout="50000" />
    <dubbo:protocol name="dubbo" port="${dubbo.service.port}" accesslog="true"/>
    
    <bean id="mobileService" class="cn.zhengyong.service.impl.MobileService"/>
    <bean id="mobileRestfulService" class="cn.zhengyong.service.restful.impl.MobileHttpService"/>
    <!--发布dubbo服务-->
    <dubbo:service interface="cn.zhengyong.api.service.intf.IMobileService" ref="mobileService" protocol="dubbo" version="${dubbo.service.mobile.version}" />
    <!--发布restful服务-->
    <dubbo:service interface="cn.zhengyong.api.service.intf.IMobileService"  ref="mobileRestfulService" registry="N/A" protocol="rest" version="${dubbo.service.mobile.version}" />
</beans>

restful 配置

<?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:dubbo="http://code.alibabatech.com/schema/dubbo"
       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
    <dubbo:protocol name="rest" server="servlet" port="${app.port}"/>
</beans>



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值