In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
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 introduces "how the Spring Cloud Alibaba Nacos module loads the configuration information by default". In the daily operation, I believe that many people have doubts about how the Spring Cloud Alibaba Nacos module loads the configuration information by default. The editor consulted all kinds of materials and sorted out simple and useful operation methods. I hope it will be helpful to answer the question of "how the Spring Cloud Alibaba Nacos module loads configuration information by default"! Next, please follow the editor to study!
Loading rule
In the previous article, our example was done entirely with the default configuration. So let's take a look at how the Spring Cloud Alibaba Nacos module loads configuration information by default.
First, recall that in our getting started example, the configuration created in Nacos looks like this:
Data ID:alibaba-nacos-config-client.properties
Group:DEFAULT_GROUP
To disassemble it, there are three main elements, which correspond to the configuration content of the specific application as follows:
Alibaba-nacos-config-client in Data ID: corresponding to the configuration spring.cloud.nacos.config.prefix of the client. The default value is ${spring.application.name}, that is, the service name.
Properties in Data ID: the configuration spring.cloud.nacos.config.file-extension of the corresponding client. The default is properties.
The value DEFAULT_GROUP of Group: the configuration spring.cloud.nacos.config.group of the corresponding client. The default value is DEFAULT_GROUP.
The configuration rules to be loaded in applications with default values are: Data ID=$ {spring.application.name} .properties, Group=DEFAULT_GROUP.
Next, let's make some hypothetical examples to make it easier for you to understand the relationship between these configurations:
Example 1: if we do not want to load through the service name, we can add the following configuration to load the configuration content of Data ID=example.properties,Group=DEFAULT_GROUP:
Spring.cloud.nacos.config.prefix=example
Example 2: if we want to load the content in yaml format instead of Properties format, we can load the configuration content of Data ID=example.yaml,Group=DEFAULT_GROUP by configuring as follows:
Spring.cloud.nacos.config.prefix=examplespring.cloud.nacos.config.file-extension=yaml
Example 3: if we manage the configuration by grouping, we can load the configuration content of Data ID=example.yaml,Group=DEV_GROUP through the following configuration:
Spring.cloud.nacos.config.prefix=examplespring.cloud.nacos.config.file-extension=yamlspring.cloud.nacos.config.group=DEV_GROUP at this point, the study on "how the Spring Cloud Alibaba Nacos module loads configuration information by default" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.