In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces the example analysis of springboot+dubbo+zookeeper, which is very detailed and has certain reference value. Friends who are interested must finish it!
Start dubbo,java-jar dubbo-admin-0.0.1-SNAPSHOT.jar under the path of dubbo-admin-0.0.1-SNAPSHOT.jar
Dubbo-admin-0.0.1-SNAPSHOT.jar 's bag needs to be packed in advance.
Start zkServer.cmd and zkCli.cmd for zookeeper
Needed dependency
Org.apache.dubbo dubbo-spring-boot-starter 2.7.3 com.github.sgroschupf zkclient 0.1 org.apache.curator curator-framework 2.12.0 org.apache. Curator curator-recipes 2.12.0 org.apache.zookeeper zookeeper 3.4.14 org.slf4j slf4j-log4j12 Org.springframework.boot spring-boot-starter-web
Both the server and the consumer need these dependencies
Server side
Set up a service on the server side
@ Component@Service / / can be scanned to register with the registry service as soon as the project is started and discover public class TickServiceImp implements TicketService {@ Override public String getTick () {return "" Today is a good day ";}}
The @ Service here is used under dubbo to register the service with the registry.
@ Component is used to inject classes into the container
The application.yml configuration is as follows
Server: port: 800customers service application name dubbo: application: name: provider-server# registry address registry: address: zookeeper://127.0.0.1:2181# those services are to be registered scan: base-packages: com.cfz.service
Start the server and view it under the port http://localhost:7001 set by zookeeper
Consumer end
First import the required dependencies (same as above)
Set up the service
The interface here should be the same as that on the server side.
The Userservice class is as follows
@ Service / / put it in the container public class Userservice {/ / if you want to get the ticket provided by provider-server, you need to go to the registry to get the service @ Reference / / reference, pom coordinates, you can define the same path of the interface name TicketService ticketService; public void buyTicket () {System.out.println ("get it in the registry" + ticketService.getTick ());}}
The application.yml configuration is as follows
The above is all the content of this article "sample Analysis of springboot+dubbo+zookeeper". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.