Involved when using Nacos as the center of the configuration, simple integration reference demo found a problem, when to take Nacos configuration corresponding dataId rule is this:
The ${prefix} - ${spring. Profiles. The active}. ${file - the extension}
Prefix for spring. The default application. The name of the value, but can be by spring configuration items. The cloud. Nacos. Config. The prefix to the configuration,
Spring. Profiles. The active is the current environment corresponding profile, details you can refer to the spring Boot document, note: when spring. Profiles. Active is empty, the corresponding connector - will also does not exist, the joining together of dataId format into ${prefix}. ${file - the extension}
File - exetension as the configuration of content data format, can be configured a spring. Cloud. Nacos. Config. The file - the extension to configure, currently only support the properties and yaml types,
Specific to my springboot test environment, in addition to specify the nacos bootstrap. Yml, local and application, yml, application - dev. Yml, application - test. Yml these did not delete, just modify all the information on the allocation center,
When I was in the bootstrap. Yml specifies in spring. The application. The name is A, spring. Cloud. Nacos. Config. The file - the extension of yaml, nor write spring. Profiles. Active, according to the rules above, corresponding dataId to find configuration server should be A.y aml,
Finally find corresponding dataId is B - test. Yaml, certainly didn't get a server configuration,
And B is a local application - test. The spring in the yml. Application. The value of the name and application. The yml specified is spring. The profiles. The active for the test,
Before this let me puzzled, I to this, there is no research has been cognition is the bootstrap loading sequence is higher than that in the application, and my ideal effect should be first according to the bootstrap configuration in the registry information to get the server configuration, according to the local application again when get to find the corresponding configuration,
The practical effect is that the bootstrap and application - x configuration has a spring at the same time. Application. The name, the effect of application - the test. The values in the yml,
Behind me test again, when in the bootstrap. Yml also specify spring. Profiles. The active for dev (application. Yml is still test), the result is corresponding dataId is C - dev. Yaml, C is application - dev. Yml in spring. The application. The value of the name,
Specific to the spring here. The profiles. Active is the bootstrap. The value of the yml
Only when the application - dev. Yml or application - test. The spring in the yml. Application. The name values are deleted, will this time the name is A, dataId is A - dev. Yml or A - test. Yml
Behind me that tested the:
Specified in the applicaiton. Yml spring. Profiles. The active test configuration, corresponding applicaiton - dev. Yml and applicaiton - the test of the spring in the yml. Application. The name is M and N respectively, the bootstrap, yml file - the extension to yaml,
1. When the bootstrap. Neither specified in the yml active also don't write the name,
Finally dataId: N - test. Yaml
2. When the bootstrap. Write the name in the yml C,
Finally dataId: N - test. Yaml
3. When the bootstrap. Active written in yml dev
Finally dataId: M - dev yaml
4. When the bootstrap. Write the dev active yml, write the name F,
Finally dataId: M - dev yaml
5. When the bootstrap. Active written in yml dev, write the name F, and delete the applicaiton - dev. Yml in the name of the value of A
Finally dataId: F - dev. Yaml
It seems that in configuration dataId, in general, to see if there are any write spring at the bootstrap. Profiles. Active, if not see application. The spring in the XML. Profiles. Active specified, based on this to find the corresponding dev or - test application file corresponding to the spring. Application. The name,
Then in accordance with such as the name - dev. The yaml to configure center to take the corresponding configuration, this configuration does take precedence over local configuration to take effect,
What is this order
CodePudding user response:
Specific loading or rely on the nacos is how to deal with, you said that is the class loader loader order order