赞
踩
已经有bms-email-service-provider提供了两组服务在nacos服务器上注册,如下图:
那么如何用调用它们?
先建立application-dubbo.yml,xxx.xxx.xxx.xxx是nacos服务器ip
#send mail dubbo consumer service 配置 dubbo: application: #name: dubbo-business-account-service-provider qos-enable: false qos-accept-foreign-ip: false # nacos集群的时候要分别注册各nacos,我认为比用nginx管理要好 registries: nacos1: address: nacos://xxx.xxx.xxx.xxx:8848 group: bms-business nacos2: address: nacos://yyy.yyy.yyy.yyy:8848 group: bms-business protocol: name: dubbo port: -1 scan: base-packages: com.freestyle.common.email.api cloud: subscribed-services: bms-email-service-provider
&esmp;然后在application.yml里面引用它:
spring:
profiles:
include: dubbo
application:
name: send-mail-consumer
cloud:
nacos:
discovery:
server-addr: xxx.xxx.xxx.xxx:8848,yyy.yyy.yyy.yyy:8848
#namespace: 1864098a-8d49-447a-ab0a-2ce2bff43166
group: bms-business
inetutils:
preferred-networks: 128.30
@Service
public class TestService {
@DubboReference
private EMailUserService eMailUserService;
public Map<String,String> test(){
return eMailUserService.getMailMapByAccountList(Arrays.asList("dgmislrh","dgmislxj"));
}
}
&esmp;&esmp;主程序要加注解@EnableDiscoveryClient:
@SpringBootApplication(exclude= {
DataSourceAutoConfiguration</
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。