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 are the three configuration modes of Spring-cloud Config Server

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

Today, I will talk to you about the three configurations of Spring-cloud Config Server, which may not be well understood by many people. in order to make you understand better, the editor has summarized the following for you. I hope you can get something from this article.

Three configurations of Spring-cloud Config Server

There are many ways to configure Spring-cloud Config Server. Today, I will introduce three configuration methods of Git,local,svn, but the official document still recommends using Git for configuration development.

All right, here we go!

1.config default Git load

Specify the git address where the configuration information is stored through spring.cloud.config.server.git.uri, such as https://github.com/xxx/config-repo

two。 Load the local development environment spring.profiles.active=nativespring.cloud.config.server.native.searchLocations=classpath:/config3. Load the local physical environment spring.profiles.active=nativespring.cloud.config.server.native.searchLocations= file:E:\\ Java\\ config4. Load the svn environment

Http://localhost:8080/{application}/{profile}/{label}, for example: http://localhost:8080/dmeo/development/trunk

# config server svnspring.cloud.config.server.svn.uri= http://localhost:8080/dmeo/development/trunkspring.cloud.config.server.svn.username=xxxspring.cloud.config.server.svn.password=xxxspring.profiles.active=subversion

PS: SVN jar package needs to be introduced in svn environment

Org.tmatesoft.svnkitsvnkitspringcloud Unified configuration Center (config server side) 1. Why use the Unified configuration Center?

1. Configuration is not easy to maintain

two。 Configure security and permissions for content

3. Updating the configuration project requires a restart

two。 Log in to github to create a project to store the configuration

3. The git address of the configured project is stored in the yml of the project.

4. Configuration in the project (Spring Cloud Config server side)

The project is both the client of eureka and the server of Config.

4.0.0 org.springframework.boot spring-boot-starter-parent 2.1.2.RELEASE com.zhu config 0.0.1-SNAPSHOT config Demo project for Spring Boot 1.8 Greenwich.RELEASE org.springframework.cloud spring-cloud-config-server Org.springframework.cloud spring-cloud-starter-netflix-eureka-client org.springframework.boot spring-boot-starter-test test org.springframework.cloud spring-cloud-dependencies ${spring-cloud.version} Pom import org.springframework.boot spring-boot-maven-plugin spring-milestones Spring Milestones https://repo.spring.io/milestone

Yml configuration

Eureka: client: service-url: defaultZone: http://localhost:8085/eureka/server: port: 8090spring: application: name: config cloud: config: server: git: uri: git@github.com:zhujin888/config-repo.git / / git address username: git account password: git password

Main class:

Package com.zhu.config;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;import org.springframework.cloud.client.discovery.EnableDiscoveryClient;import org.springframework.cloud.config.server.EnableConfigServer;@SpringBootApplication@EnableDiscoveryClient@EnableConfigServerpublic class ConfigApplication {public static void main (String [] args) {SpringApplication.run (ConfigApplication.class, args);}} 5. Create a folder on git to store configuration information

Usually deposit three copies

Dev: development

Test: testing

Pro: production

6. Visit config server

Two ways: use either one

7. Pull the remote git to the local git

Configure the local git path

Eureka: client: service-url: defaultZone: http://localhost:8085/eureka/server: port: 8090spring: application: name: config cloud: config: server: uri: git@github.com:zhujin888/config-repo.git username: password: basedir: d:\ My_Java\ anli\ gitconfig\ basedir / / configure the local git path Store the pulled configuration file after reading the above content Do you have any further understanding of the three configurations of Spring-cloud Config Server? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.

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

Development

Wechat

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

12
Report