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

How to solve the problem that multiple environment configurations in spring cloud config cannot be loaded in idea

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

Share

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

This article mainly explains "how to solve the problem of how to load multi-environment configuration in spring cloud config in idea". The content of the explanation in this article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to solve the problem that you can't load multi-environment configuration in spring cloud config in idea".

First, let's briefly talk about some concepts of the configuration center of spring cloud.

There are many ways to configure Spring-cloud Config Server

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

2. Load the local development environment

Spring.profiles.active=native

Spring.cloud.config.server.native.searchLocations=classpath:/config

So my current configuration is roughly as follows (yml)

Spring: application: name: config-center profiles: active: native cloud: config: server: native: classpath:/configs/ {profile} # searchLocations: file:/d:/configs/ {profile} git: uri: https://xx.com/xxx/cloud-service-configs.git default-label: master force-pull: true searchPaths:'{profile}'

Because active: native is configured, the local configuration is used here

We have a directory of configs.dev here.

The specific micro-service needs to be configured as follows to obtain the configuration under the dev directory (take the product provider micro-service as an example)

Spring: application: name: productprovider cloud: config: discovery: enabled: trueserviceId: config-center profile: dev

To configure multiple environments, for example, we need to set up a local configuration.

If we set up a folder like this,

The result is to actually create a single folder for configs.local, rather than a local folder under the configs folder.

The situation is the same here under windows,mac, so the right thing to do is to go to the configs directory and manually create a local folder (windows, please operate under Explorer)

Copy the configuration file you need to the local directory to modify it, and then modify the configuration of the microservice to be started.

Spring: application: name: productprovider cloud: config: discovery: enabled: trueserviceId: config-center# profile: dev profile: local

You can use the configuration center in a multi-configuration environment.

Thank you for reading, the above is "how to solve the problem of how to load multi-environment configuration in spring cloud config in idea". After the study of this article, I believe you have a deeper understanding of how to solve the problem of multi-environment configuration in idea that can not be loaded in spring cloud config. The specific use also needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

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