第一个dubbo项目

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/han_xiaoxue/article/details/87281795

创建四个项目

下载项目地址:
https://download.csdn.net/download/han_xiaoxue/10957427
在这里插入图片描述

消费者项目

在这里插入图片描述

dubbo-consumer.xml

在这里插入图片描述

生产者项目

在这里插入图片描述

dubbo-provider.xml

在这里插入图片描述

DubboProvider

public class DubboProvider {
	
	private static final Log log = LogFactory.getLog(DubboProvider.class);

	public static void main(String[] args) {
		try {
			ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("classpath:spring/spring-context.xml");
			context.start();
		} catch (Exception e) {
			log.error("== DubboProvider context start error:",e);
		}
		synchronized (DubboProvider.class) {
			while (true) {
				try {
					DubboProvider.class.wait();
				} catch (InterruptedException e) {
					log.error("== synchronized error:",e);
				}
			}
		}
	}
    
}

运行

启动zookeper

https://blog.csdn.net/han_xiaoxue/article/details/86747509
1、运行 DubboProvider 里的main方法,启动生产者项目
2、tomcat中启动 消费者项目
在这里插入图片描述
3、访问结果
用户名输入为空的时候,点击登录 会调用服务接口 查询出某表的条数。显示到下方。


成功!


在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/han_xiaoxue/article/details/87281795