try {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("classpath:spring/spring-context.xml");
//spring-context.xml配置加入
/* <import resource="dubbo-provider.xml" /> */
context.start();
} catch (Exception e) {
log.error("== DubboProvider context start error:",e);
}
//或者 System.in.read();
synchronized (DubboProvider.class) {
while (true) {
try {
DubboProvider.class.wait();
} catch (InterruptedException e) {
log.error("== synchronized error:",e);
}
}
}
二、使用Servlet容器运行(Tomcat、Jetty等)—-不可取 缺点:增长复杂性(端口、管理) 浪费资源(内存),不必,直接建一个java工程java
3.借助Spring容器使用Dubbo框架提供的Main方法类来运行com.alibaba.dubbo.container.Main 注意经过这种方式打包启动jar 须要把项目依赖jar包放到一块儿这里经过Main配置依赖目录关系 启动命令 java -jar XXXX .jar 或者用shell启动 —建议使用 优势:框架自己提供(com.alibaba.dubbo.container.Main) 可实现优雅关机(ShutdownHook)web
//注意点: spring-context.xml <import resource="classpath:spring/spring-xxx.xml" />
里边的:
dubbo.registry.address=zookeeper://127.0.0.1:2181#链接的是本地的zk
dubbo.admin.root.password=root
dubbo.admin.guest.password=guest spring
分为java -jar,shell启动两种。可是配置啊代码啊都是同样发的shell
java -jar没有dubbo服务没有注册到zk上(待研究)
api
可是没有注册到zk上tomcat
zkCli.sh
zk:ls /
zk: [registry,zookeeper],没有dubbo
dubbo-admin 上也没有
问题出在了哪儿app
,详见http://blog.csdn.net/yuguiyang1990/article/details/8796726(应该不侵权吧,帮做者杨名,写的很详细)
框架