In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article is about how to implement service registration consul in Spring Cloud. The editor thinks it is very practical, so share it with you as a reference and follow the editor to have a look.
A brief introduction to consul
Consul has the following properties:
Service Discovery: consul registers services through http, and services and services interact with each other.
Service health monitoring
Key/value storage
Multiple data centers
Consul can run on machines such as mac windows linux.
II. Consul installation
Linux
$mkdir-p $GOPATH/src/github.com/hashicorp & & cd $! $git clone https://github.com/hashicorp/consul.git$ cd consul$ make bootstrap$ make bootstrap
Install under windows:
See how to install consul under windows
III. Construction project
Build a springboot project for consul-miya, and import the dependent pring-cloud-starter-consul-discovery, which depends on the file:
4.0.0 com.forezp consul-miya 0.0.1-SNAPSHOT jar consul-miya Demo project for Spring Boot org.springframework.boot spring-boot-starter-parent 1.5.2.RELEASE UTF-8 UTF-8 1.8 org.springframework.cloud spring-cloud-starter-consul -discovery org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-starter-test test org.springframework.cloud spring-cloud-dependencies Dalston.RELEASE Pom import org.springframework.boot spring-boot-maven-plugin
Add the annotation @ EnableDiscoveryClient to its entry file ConsulMiyaApplication to enable service discovery:
@ SpringBootApplication@EnableDiscoveryClient@RestControllerpublic class ConsulMiyaApplication {@ RequestMapping ("/ hi") public String home () {return "hi, IBM miya";} public static void main (String [] args) {new SpringApplicationBuilder (ConsulMiyaApplication.class) .web (true) .run (args);}}
Specify the port of the consul service in its configuration file application.yml as 8500:
Spring: cloud: consul: host: localhost port: 8500 discovery: healthCheckPath: ${management.contextPath} / health healthCheckInterval: 15s instance-id: consul-miya application: name: consul-miyaserver: port: 8502
Start the project, visit localhost:8500, and you can find that consul-miya is registered.
Thank you for reading! This is the end of the article on "how to implement service registration consul in Spring Cloud". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, you can share it out for more people to see!
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.