SpringMVC關於dubbo的配置檔案
阿新 • • 發佈:2018-11-21
公司的老專案改造,網上找的xml真的不知所云,留此筆記
dubbo-provider.xml
<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提供方 --> <!-- 1:名稱 計算機 區別 唯一 --> <dubbo:application name="service-product"/> <!-- 2:設定註冊中心 地址 zookeeper在哪裡 redis ... --> <!-- <dubbo:registry address="20.4.16.9:2181,20.4.16.10:2181,20.4.16.35:2181" protocol="zookeeper" /> --> <dubbo:registry address="20.4.16.35:2181" protocol="zookeeper" /> <!-- 只訂閱("只訂閱”指的是需要做開發除錯的服務提供者,只向註冊中心訂閱其所依賴的服務 ,但不向註冊中心註冊其本身可以提供的服務),不註冊,正在開發的服務不提供服務, 已經開發完成的可以通過直連執行 --> <!-- <dubbo:registry address="20.4.16.9:2181" protocol="zookeeper" regiest="false" /> --> <!-- 只註冊,不定閱 --> <!-- <dubbo:registry address="20.4.16.9:2181" protocol="zookeeper" subscribe="false " /> --> <!-- 3:dubbo://192.168.39.80:20880 預設 設定提供服務的埠號 --> <dubbo:protocol port="20880" name="dubbo"/> <!-- 4: 暴露實現類--> <dubbo:service interface="com.ljp.Interface.userService" ref="userImpl" group="first"/> <!-- <dubbo:service interface="com.ljp.Interface.userService" ref="uusseImpl" group="secend"/> --> <!-- 監控中心配置,protocol="registry",表示從註冊中心發現監控中心地址 --> <!-- <dubbo:monitor protocol="registry"/> --> <!-- 當ProtocolConfig和ServiceConfig某屬性沒有配置時,採用此預設值 ,執行緒超時時間,固定大小100,可接受1000請求 <dubbo:provider timeout="10000" threadpool="fixed" threads="100" accepts="1000" /> --> <!-- 連線失敗 retries嘗試次數--> <!-- <dubbo:service retries="0" interface="wusc.edu.pay.facade.boss.service.GlobalSetFacade" ref="globalSetFacade" /> --> </beans>
dubbo-consumer.xml
<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消費方 --> <!-- 1:名稱 計算機 區別 唯一 --> <dubbo:application name="console"/> <!-- <dubbo:protocol name="dubbo" port ="21811"></dubbo:protocol> --> <!-- 2:設定註冊中心 地址 zookeeper在哪裡 redis ... --> <!-- <dubbo:registry address="20.4.16.9:2181,20.4.16.10:2181,20.4.16.35:2181" protocol="zookeeper"/> --> <dubbo:registry address="20.4.16.35:2181" protocol="zookeeper"/> <!-- 4: 呼叫此介面對應的實現類 單位毫秒--> <dubbo:reference interface="com.ljp.Interface.userService" id="userImpl" group="first"/> <dubbo:reference interface="com.ljp.Interface.userService" id="uusseImpl" group="secend"/> <!-- 全域性設定 --> <dubbo:consumer timeout="600000" check="false"/> <!-- 監控中心配置,protocol="registry",表示從註冊中心發現監控中心地址 --> <!-- <dubbo:monitor protocol="registry"/> --> <!--直連提供者,繞開zookeeper,url直接指提供者(即本伺服器ip),若有多個","隔開 --> <!-- <dubbo:reference interface="com.ljp.Interface.User" id="uusseImpl" ur="dubbo://20.4.2.3:20880" group="secend"/> --> </beans>
都是spring需要的配置檔案,放在mvc配置裡面是不行的。