Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the configuration center of springcloud4?

2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article is to share with you about the springcloud4 configuration center, the editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.

1. Create a new configuration center module

Note: the configuration code of the remote warehouse is basically the same as that of the client or server.

1.1 main method

@ SpringBootApplication@EnableEurekaClient / / join the registry @ EnableConfigServer / / enable configuration server public class UserProviderApplication_6666 {public static void main (String [] args) {SpringApplication.run (UserProviderApplication_6666.class, args);}}

1.2 application configuration

Server: # Port number of the configuration center port: 6666 eureka: client: service-url: defaultZone: http://peer1000:1000/eureka/, Http://peer1001:1001/eureka/ # can use ip to register instance: prefer-ip-address: truespring: application: name: config-server cloud: config: server: git: # is the configuration center address uri: https://gitee.com/ccjdk/springcloud-demo.git username:. Password:.

1.3 pom

Org.springframework.boot spring-boot-starter-web org.springframework.boot spring-boot-starter-test org.springframework.cloud spring-cloud-starter-netflix-eureka-client org.springframework.cloud spring-cloud-config-server2. Client (profile name is bootstrap.yml, priority is higher than application)

2.1 based on the client in springcloud3

Add in pom

Org.springframework.cloud spring-cloud-starter-config

2.2 bootstrap.yml configuration

The total name of spring: cloud: config: # name+profile is the name on the cloud or github application-getting-test name: application-getting # github above the name profile: test # environment # master is the name of the branch on the repository and is the default label: master # branch uri: http://localhost:6666 # configure the central server # when clustering You can also replace the name of the configuration center server uri discovery: # enabled: true # service-id: CONFIG-SERVER # the name of the configuration center in the registry eureka: client: service-url: defaultZone: http://peer1000:1000/eureka/,http://peer1001:1001/eureka/ instance: prefer-ip-address: true # shows the real ip of the client

2.3 run the main method, and the port number becomes the port number in the remote repository

The above is what the springcloud4 configuration center is like, and the editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please 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.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report