Ich habe eine Spring Boot-Anwendung, die Konfiguration von Spring Cloud-Konfigurationsserver (nativer Modus). Die Basis application.yml Datei in der Config-Position durch den Konfigurationsserver geladen enthält folgende Komponenten:Spring Profile nicht ordnungsgemäß beim Abrufen von Config von Spring Cloud Config Server
eureka:
client:
service-url:
defaultZone: ${BOOT_EUREKA_LOCATIONS:http://instance1.localhost:7761/eureka,http://instance2.localhost:7762/eureka,http://instance3.localhost:7763/eureka}
register-with-eureka: true
---
spring:
profiles: test
eureka:
client:
register-with-eureka: false #no registration on Eureka when testing
service-url:
defaultZone: ${BOOT_EUREKA_LOCATIONS:http://sparky:8761/eureka}
Wenn der Endpunkt für die Config Server (http://mygateway/config-server/myapp/test) schlagen, erhalte ich die folgenden wieder für die „myapp“ Anwendung läuft in Profil "test":
{
"name": "myapp",
"profiles": [
"test"
],
"label": null,
"version": null,
"state": null,
"propertySources": [
{
"name": "file:////wherever/application.yml#test",
"source": {
"spring.profiles": "test",
"eureka.client.register-with-eureka": false,
"eureka.client.service-url.defaultZone": "${BOOT_EUREKA_LOCATIONS:http://sparky:8761/eureka}"
}
},
{
"name": "file:////whereever/application.yml",
"source": {
"eureka.client.service-url.defaultZone": "${BOOT_EUREKA_LOCATIONS:http://instance1.localhost:7761/eureka,http://instance2.localhost:7762/eureka,http://instance3.localhost:7763/eureka}"
myApp Wenn im Testprofil ausgeführt wird, ist der Wert von eureka.client.service-url.defaultZone http://instance1.localhost:7761/eureka,http://instance2.localhost:7762/eureka,http://instance3.localhost:7763/eureka, was unerwartet ist.
Ich hätte erwartet, den Eintrag im Testprofil zu überschreiben (wie es tut, wenn Sie die application.yml lokal haben). Gedanken darüber, warum ich den Wert aus dem "Test" -Profil nicht bekommen würde, wenn ich den Wert in myApp verwende?
Meine Absicht wäre, die "Standard" -Werte an der Spitze hinzuzufügen, und das "Profil" überschreiben alle nicht standardmäßigen Standardeinstellungen.
Update: myApp/env den "application.yml # test" geladen nicht zeigt, aber es ist das Testprofil zeigt, sondern nur die Standardwerte zurückgesetzt zurück aus der Config Server (nicht die #test ist):
{
"profiles": [
"test"
],
"server.ports": {
"local.server.port": 7761
},
"configService:file:////wherever/application.yml": {
"eureka.client.service-url.defaultZone": "http://instance1.localhost:7761/eureka,http://instance2.localhost:7762/eureka,http://instance3.localhost:7763/eureka"
Was sagt myApp '/ env'? – spencergibb
Zusätzliche Informationen hinzugefügt, um Ihre Frage zu beantworten. Große Frage, und kann zur Antwort führen. – LetsBeFrank