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 Consumer {
public static void main(String[] args) {
HelloService helloService = DubboReferer.get(HelloService.class);
String result = helloService.sayHello("Dubbo");
System.out.println(result);
}
}
<dubbo:reference interface="com.example.HelloService" id="helloService" url="dubbo://localhost:20880" />
<dubbo:registry address="zookeeper://localhost:2181" />