当前位置:网站首页>Develop consumer client as micro service

Develop consumer client as micro service

2022-04-23 22:10:00 Leon_ Jinhai_ Sun

# 1. Create a project and introduce consul Client dependency 
 <!-- introduce consul rely on -->
<dependency>
  <groupId>org.springframework.cloud</groupId>
  <artifactId>spring-cloud-starter-consul-discovery</artifactId>
</dependency>

# 2. To write properties To configure 
server.port=8889
spring.application.name=consulclient8889
spring.cloud.consul.host=localhost														# register consul Host of service 
spring.cloud.consul.port=8500																	# register consul The port number of the service 
spring.cloud.consul.discovery.register-health-check=false	    # close consu The health check of the service [ Not recommended ]
spring.cloud.consul.discovery.service-name=${spring.application.name} # Specify the registered service name   The default is the application name 

# 3. Start the service to see consul Interface service information 

版权声明
本文为[Leon_ Jinhai_ Sun]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/113/202204232157394617.html