Open
Description
我照着例子抄了一份消费者,一直启动不起来,希望有人提供一下帮助,哪怕帮我指出错误
代码照着 https://github.com/apache/dubbo-samples/blob/master/dubbo-samples-spring-boot/dubbo-samples-spring-boot-consumer/src/main/java/org/apache/dubbo/springboot/demo/consumer/ConsumerApplication.java 这个文件抄的,当然provider和consumer的依赖、配置也都已经照着抄过来了
具体内容就是
import cc.momas.dubbo.api.AccountService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.stereotype.Service;
@SpringBootApplication
@Service
@EnableDubbo
public class ConsumerApplication {
@DubboReference
private AccountService demoService;
public static void main(String[] args) {
ConfigurableApplicationContext context = SpringApplication.run(ConsumerApplication.class, args);
ConsumerApplication application = context.getBean(ConsumerApplication.class);
String result = application.doSayHello("world");
System.out.println("result: " + result);
}
public String doSayHello(String name) {
return demoService.sayHello(name);
}
}
如果还需要更多信息的请,我的代码在 https://github.com/Sod-Momas/playground/tree/master/playground-apache-dubbo 这里
Metadata
Metadata
Assignees
Labels
No labels