dubbo框架的第一个demo

本文展示了一个基于Dubbo框架的服务提供者实现示例。通过定义接口DemoService和其实现类DemoServiceImpl,提供了sayHello方法。使用ClassPathXmlApplicationContext启动并注册服务,配置了dubbo协议、端口和注册中心地址。

public interface DemoService {
String sayHello(String name);
}

public class DemoServiceImpl implements DemoService{

@Override
public String sayHello(String name) {
	
	return "Hello"+name;
}

}
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class Provider {
public static void main(String[] args) throws Exception {
System.setProperty(“java.net.preferIPv4Stack”, “true”);
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[]{“Test/src/com/sxf/provider.xml”});
context.start();
System.out.println(“Provider started.”);
System.in.read();
}
}


<dubbo:application name=“demo-provider”/>

<dubbo:registry address=“multicast://224.5.6.7:1234”/>

<dubbo:protocol name="dubbo" port="20880"/>

<bean id="demoService" class="org.apache.dubbo.demo.provider.DemoServiceImpl"/>

<dubbo:service interface="org.apache.dubbo.demo.DemoService" ref="demoService"/>
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值