依赖
代码语言:javascript复制implementation 'com.alibaba:dubbo:2.6.0'
implementation ('com.101tec:zkclient:0.10'){
exclude group: 'org.slf4j',module: 'slf4j-log4j12'
exclude group: 'log4j',module: 'log4j'
}
配置
resources/config/dubbo.xml
代码语言:javascript复制<?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:application name="服务名" />
<!--对应zk的地址-->
<dubbo:registry address="zookeeper://***********" ></dubbo:registry>
//需要注入的接口
<dubbo:reference id="dataService" interface="com.DataService" timeout="300000" check="false"/>
</beans>
主程序上加 @ImportResource({“classpath:config/dubbo.xml”})
注入
代码语言:javascript复制@Resource
private DataService ataService;