公司的老项目改造,网上找的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配置里面是不行的。