dubbo服务即做消费者又做提供者
spring-dubbo.xml
配置,只需要一个配置文件
<?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:context="http://www.springframework.org/schema/context"
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://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd" default-lazy-init="false">
<context:property-placeholder
file-encoding="UTF-8" ignore-resource-not-found="true"
location="classpath:config.properties"/>
<import resource="spring-context.xml" />
<dubbo:application name="tower-user-service"/>
<dubbo:registry address="zookeeper://127.0.0.1:2181" />
<!-- 让dubbo自行找一个可用的port -->
<dubbo:protocol name="dubbo" port="-1" />
<dubbo:service interface="com.gml.tower.user.UserService" ref="userService"
timeout="30000" version="1.0" retries="0"></dubbo:service>
<dubbo:reference id="commonService" interface="com.gml.tower.common.CommonService" timeout="30000"
check="false" version="1.0" retries="0"></dubbo:reference>
</beans>
dubbo协议缺省端口为20880,rmi协议缺省端口为1099,http和hessian协议缺省端口为80;如果配置为-1 或者 没有配置port,则会分配一个没有被占用的端口。Dubbo 2.4.0+,分配的端口在协议缺省端口的基础上增长,确保端口段可控。