
近期在研究dubbo框架
相信看到這篇的,dubbo的基礎應該都有了
zookeeper的搭建走了點彎路,配置起來各種麻煩,媽的搞的好煩。
正好一直想用一下docker,但對docker只是有個簡單的概念。
用了一晚上去研究docker,之後發現真的好用
搭建個zookeeper就跟玩似的。
這裡記錄一下遇到的一些坑!
1、springboot引入dubbo的配置文件
網上搜索了一下,大概的兩種方式
1、 這種方式是通過 ClassPathXmlApplicationContext 加載xml來獲取上下文Context啟動
1 @SpringBootApplication
2 3 public class WreserveApplication {
4
5 public static void main(String[] args) throws IOException, InterruptedException {
6 ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[]{"dubbo-provider.xml"});
7 context.start();
8 System.in.read(); // press any key to exit
9 }
10
11 }
2、通過 @ImportResource({ "classpath:dubbo-provider.xml" }) 加載。
1 @SpringBootApplication
2 @ImportResource({ "classpath:dubbo-provider.xml" })
3 public class WreserveApplication {
4 @Bean
5 public CountDownLatch closeLatch() {
6 return new CountDownLatch(1);
7 }
8
9 public static void main(String[] args) throws IOException, InterruptedException {
10 ConfigurableApplicationContext context = SpringApplication.run(WreserveApplication.class, args);
11 CountDownLatch closeLatch = context.getBean(CountDownLatch.class);
12 closeLatch.await();
13
14 }
15
16 }
2、dubbo-provider.xml和dubbo-consumer.xml中需要注意的一些問題
dubbo-provider.xml
<beans>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation="http://www.springframework.org/schema/beanshttp://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">;
<application>/<beans>
<registry>
<protocol>
<bean>
<service>
dubbo-consumer.xml
1、消費者要訪問提供者,
<reference>
interface="com.zhyonk.wreserve.service.HelloService" protocol="dubbo"
/<reference>閱讀更多 炸了呀 的文章