dobbo配置

来源:互联网 发布:php list注意 编辑:程序博客网 时间:2024/06/05 09:28

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

[plain] view plain copy
  1. <?xml version="1.0"?>  
  2. <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"  
  3.         "http://java.sun.com/dtd/web-app_2_3.dtd">  
  4.   
  5. <web-app>  
  6.   
  7.     <context-param>  
  8.         <param-name>contextConfigLocation</param-name>  
  9.         <param-value>classpath*:spring/service-root.xml</param-value>  
  10.     </context-param>  
  11.   
  12.     <!--this listener must be defined before the spring listener-->  
  13.     <listener>  
  14.         <listener-class>com.alibaba.dubbo.remoting.http.servlet.BootstrapListener</listener-class>  
  15.     </listener>  
  16.   
  17.     <listener>  
  18.         <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>  
  19.     </listener>  
  20.   
  21.     <servlet>  
  22.         <servlet-name>dispatcher</servlet-name>  
  23.         <servlet-class>com.alibaba.dubbo.remoting.http.servlet.DispatcherServlet</servlet-class>  
  24.         <load-on-startup>1</load-on-startup>  
  25.     </servlet>  
  26.   
  27.     <servlet-mapping>  
  28.         <servlet-name>dispatcher</servlet-name>  
  29.         <url-pattern>/*</url-pattern>  
  30.     </servlet-mapping>  
  31. </web-app>  

dubbo 配置文件

[html] view plain copy
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <beans xmlns="http://www.springframework.org/schema/beans"  
  3.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"  
  4.        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">  
  5.   
  6.     <!--声明dubbo服务基本信息-->  
  7.     <dubbo:application name="dobboProjectName" owner="zhengyong" organization="dubbox"/>  
  8.     <dubbo:registry protocol="zookeeper"  group="${zookeeper.root}"  address="${zookeeper.address}" timeout="50000" />  
  9.     <dubbo:protocol name="dubbo" port="${dubbo.service.port}" accesslog="true"/>  
  10.       
  11.     <bean id="mobileService" class="cn.zhengyong.service.impl.MobileService"/>  
  12.     <bean id="mobileRestfulService" class="cn.zhengyong.service.restful.impl.MobileHttpService"/>  
  13.     <!--发布dubbo服务-->  
  14.     <dubbo:service interface="cn.zhengyong.api.service.intf.IMobileService" ref="mobileService" protocol="dubbo" version="${dubbo.service.mobile.version}" />  
  15.     <!--发布restful服务-->  
  16.     <dubbo:service interface="cn.zhengyong.api.service.intf.IMobileService"  ref="mobileRestfulService" registry="N/A" protocol="rest" version="${dubbo.service.mobile.version}" />  
  17. </beans>  

restful 配置

[html] view plain copy
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <beans xmlns="http://www.springframework.org/schema/beans"  
  3.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"  
  4.        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">  
  5.     <dubbo:protocol name="rest" server="servlet" port="${app.port}"/>  
  6. </beans>  
原创粉丝点击