In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces "how to solve the problem that the configuration file cannot be read by the remote call of the nacos configuration center". In the daily operation, it is believed that many people have doubts about how to solve the problem that the remote call of the nacos configuration center can not read the configuration file. The editor consulted all kinds of materials and sorted out a simple and useful operation method. Hope to answer the "nacos configuration center remote call can not read the configuration file how to solve" help! Next, please follow the editor to study!
Configuration file cannot be read by remote call of nacos configuration center
1. Due to the requirements of the company, nacos has been configured with a namespace. At the beginning, I went astray. )
In order to better distinguish between configuration files, we created two namespaces, dev and test. While we were learning, we did not create these namespaces, so we used them all the time. After creating the namespaces, we could not read the configuration files.
Then after adding namespaces, you need to support namespaces in the configuration file. For example, if you create group, you must specify group in the configuration file, otherwise the configuration file cannot be called. We use the default group, which does not require configuration.
The configuration file is as follows:
Server: port: 8001spring: application: name: mycloud-gateway cloud: nacos: config: file-extension: yml server-addr: http://baidu.top namespace: b5ccc73d-b020-46b9-8f5f-cc88062d4fc0 discovery: server-addr: http://baidu.top profiles: active: dev quotes a section of the official document below
Configure the address and application name of Nacos server in bootstrap.properties
Spring.cloud.nacos.config.server-addr=127.0.0.1:8848 spring.application.name=example
Description: you need to configure spring.application.name because it forms part of the Nacos configuration management dataId field.
In Nacos Spring Cloud, the full format of dataId is as follows:
${prefix}-${spring.profile.active}. ${file-extension}
Prefix defaults to the value of spring.application.name, which can also be configured through the configuration item spring.cloud.nacos.config.prefix.
Spring.profile.active is the profile corresponding to the current environment. For more information, please see the Spring Boot documentation. Note: when spring.profile.active is empty, the corresponding connector-will not exist, and the splicing format of dataId will become ${prefix}. ${file-extension}
File-exetension is the data format of the configuration content, which can be configured through the configuration item spring.cloud.nacos.config.file-extension. Currently, only properties and yaml types are supported.
When you are a beginner, you must read the official documents.
Configuring nacos-related information in a local project does not work troubleshooting
The pit that cannot read the contents of the nacos configuration center
This is really outrageous. I'll take it.
This is the wrong configuration.
Error content:
Make sure everything else is fine, but you just can't read the configuration.
This is the correct configuration.
Excuse me? With countless versions of SpringCloud SpringBoot and Nacos, the windows platform linux platform all tried it, and it turned out to be because this was written wrong (and I don't know what's wrong with it, what's the difference … )
At this point, on the "nacos configuration center remote call can not read the configuration file how to solve" on the end, 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.