dubbo框架的第一個demo
阿新 • • 發佈:2018-12-05
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"/>