dubbo之dubbo协议使用
发表于:2025-12-02 作者:千家信息网编辑
千家信息网最后更新 2025年12月02日,普通接口及实现类public interface DemoService{ String sayHello(String msg);}public class DemoServiceImpl i
千家信息网最后更新 2025年12月02日dubbo之dubbo协议使用
普通接口及实现类
public interface DemoService
{
String sayHello(String msg);
}
public class DemoServiceImpl implements DemoService
{
public String sayHello(String msg)
{
return "hello " + msg;
}
}
服务提供者配置
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">
服务消费者配置
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">
运行测试
public class Provider
{
public static void main(String[] args) throws Exception
{
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("dubbo-dubbo-provider.xml");
context.start();
System.in.read(); // 按任意键退出
}
}
public class Consumer
{
public static void main(String[] args) throws Exception
{
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("dubbo-dubbo-consumer.xml");
context.start();
DemoService demoService = (DemoService)context.getBean("demoService"); // 获取远程服务代理
String hello = demoService.sayHello("world"); // 执行远程方法
System.err.println( hello ); // 显示调用结果
}
}
直连模式
服务提供者,不用将服务注册到注册中心,并在dubbo:service配置中增加registry="N/A";
同时,服务消费者也不需要通过注册中心发现服务,并在dubbo:reference配置中增加url="dubbo://localhost:20880"直连地址.
相反,则通过注册中心来获取连接地址.
服务
配置
地址
提供者
消费者
消费
普通
不用
同时
接口
方法
模式
结果
代理
测试
运行
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
现在网络安全行业前景怎么样
手机提示服务器密码更改
延时摄影红石服务器
软件开发合同逾期约定
我的世界梦想精灵谷服务器电脑
服务器三个小电视灯一直闪
高质量网络安全手抄报
姜堰区直销网络技术
网络安全纵深防御系统
湖南师大游戏软件开发
广东省网络安全培训班通讯录
服务器掉域后怎么登陆
网络安全在哪个城市就业前景
网络安全审查信息
深圳天拓网络技术
经侦资金分析软件开发
rfam是什么数据库
领英服务器在美国 安全吗
人脸识别软件开发费用
服务器上传大小限制
怎么拦截本机发送到服务器的数据
上海大学 网络安全 论文
it中软件开发都有什么
网站服务器管理什么单位最大
查看服务器未挂载硬盘
方舟服务器密码
健全网络安全体系
关于关键基础设施网络安全法
烟草贯彻落实网络安全应急
联通网络安全专家