public interface HelloService {
String sayHello(String name);
}
public class HelloServiceImpl implements HelloService {
public String sayHello(String name) {
return "Hello, " + name;
}
}
<dubbo:service interface="com.example.HelloService" ref="helloService"/>
<bean id="helloService" class="com.example.HelloServiceImpl"/>
public class HelloConsumer {
public static void main(String[] args) {
HelloService helloService = DubboReferer.getProxy(HelloService.class, "zookeeper://127.0.0.1:2181");
String result = helloService.sayHello("Dubbo");
System.out.println(result);
}
}
<dubbo:reference interface="com.example.HelloService" id="helloService"
url="dubbo://localhost:20880"/>