Recent research on the Dubbo framework
Believe to see this blog, the foundation of Dubbo should have
Zookeeper set up a little detour, the configuration of all kinds of trouble, Mom's good annoying.
Just wanted to use Docker, but there was a simple concept for Docker.
Spent the night studying Docker and found it really useful.
Build a zookeeper and play it.
Here is a record of some of the pits encountered!
1, Springboot introduction of Dubbo configuration file
Search the internet for a bit, probably two ways
1. This is done by Classpathxmlapplicationcontext loading the XML to get contextual context start
1 @SpringBootApplication2 3 Public classwreserveapplication {4 5 Public Static voidMain (string[] args)throwsIOException, interruptedexception {6Classpathxmlapplicationcontext context =NewClasspathxmlapplicationcontext (Newstring[]{"Dubbo-provider.xml"});7 Context.start ();8System.in.read ();//Press any key to exit9 }Ten One}
2. Load by @ImportResource ({"Classpath:dubbo-provider.xml"}).
1 @SpringBootApplication2@ImportResource ({"Classpath:dubbo-provider.xml" })3 Public classwreserveapplication {4 @Bean5 PublicCountdownlatch Closelatch () {6 return NewCountdownlatch (1);7 }8 9 Public Static voidMain (string[] args)throwsIOException, interruptedexception {TenConfigurableapplicationcontext context = Springapplication.run (wreserveapplication.class, args); OneCountdownlatch Closelatch = Context.getbean (countdownlatch.class); A closelatch.await (); - - } the -}
2. Some problems needing attention in dubbo-provider.xml and Dubbo-consumer.xml
Dubbo-provider.xml
<?XML version= "1.0" encoding= "UTF-8"?><Beansxmlns= "Http://www.springframework.org/schema/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/beans http://www.springframework.org/schema/beans/ Spring-beans-2.5.xsd Http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd "> <dubbo:applicationname= "Demo-provider"/> <!--Use Multicast Registry Center to export service - <Dubbo:registryAddress= "zookeeper://192.168.99.100:2181"/> <!--Use Dubbo protocol to export service on port 20880 - <Dubbo:protocolname= "Dubbo"Port= "20880"/> <!--service implementation, as same as regular local bean - <BeanID= "HelloService"class= "Com.zhyonk.service.Impl.HelloServiceImpl"/> <!--Declare the service interface to be exported - <Dubbo:serviceInterface= "Com.zhyonk.service.HelloService"ref= "HelloService"/> </Beans>
Dubbo-consumer.xml
<?XML version= "1.0" encoding= "UTF-8"?><Beansxmlns= "Http://www.springframework.org/schema/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/beans http://www.springframework.org/schema/beans/spring-beans.xsd Http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd "> <dubbo:applicationname= "Wreserve-wechat"></dubbo:application> <!--Zookeeper Registration Center - <Dubbo:registryAddress= "zookeeper://192.168.99.100:2181"></Dubbo:registry> <Dubbo:consumerCheck= "false"Timeout= "60000" /> <!--generate a remote service proxy that can be used like a local bean demoservice - <dubbo:referenceID= "HelloService"Interface= "Com.zhyonk.wreserve.service.HelloService"Protocol= "Dubbo"Timeout= "15000" /></Beans>
1, consumers to access the provider,
<id= "HelloService" interface= " Com.zhyonk.wreserve.service.HelloService " protocol=" Dubbo "
<!--service implementation, as same as regular local bean - <BeanID= "HelloService"class= "Com.zhyonk.service.Impl.HelloServiceImpl"/> <!--Declare the service interface to be exported - <Dubbo:serviceInterface= "Com.zhyonk.service.HelloService"ref= "HelloService"/>
One of the interface must require the same path, or not correspond, the following situation will occur
Under normal circumstances, the dubbo-admin will show
2, if you do not have to build trouble, you can use the site to automatically generate http://start.dubbo.io/
We'll be here first, sleep.
Springboot under the Dubbo, zookeeper combined use