spring boot集成Dubbo
APIproviderdubbo:application:#指定名称name: myProviderregistry:address: zookeeper://192.168.217.131:2181?backup=192.168.217.131:2182,192.168.217.131:2183timeout: 30000#配置服务所使用的协议protocol:name: dubboport:
·
API
provider
dubbo:
application:
#指定名称
name: myProvider
registry:
address: zookeeper://192.168.217.131:2181?backup=192.168.217.131:2182,192.168.217.131:2183
timeout: 30000
#配置服务所使用的协议
protocol:
name: dubbo
port: 20880
scan:
base-packages: com.wyt.springbootdubbo_provider.service.impl
package com.wyt.springbootdubbo_provider.service.impl;
import com.wyt.dubbo.service.DemoDubboService;
import org.apache.dubbo.config.annotation.Service;
@Service
public class DemoDubboServiceImpl implements DemoDubboService {
@Override
public String showMsg(String str) {
return "hello dubbo"+str;
}
}
consumer
dubbo:
application:
#指定名称
name: myConsumer
registry:
address: zookeeper://192.168.217.131:2181?backup=192.168.217.131:2182,192.168.217.131:2183
timeout: 30000
#配置服务所使用的协议
protocol:
name: dubbo
#consumer中不用配端口,provider中需要
import com.wyt.springbootdubbo_consumer.service.DemoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class DemoController {
@Autowired
private DemoService demoService;
@RequestMapping("/getMsg")
public String getMsg(String str){
return this.demoService.getMsg(str);
}
}
更多推荐
已为社区贡献1条内容
所有评论(0)