2017-10-10 9 views
0

SpringBrowserアプリケーションがSpring Cloudコンフィグレーションサーバ(ネイティブモード)からコンフィグレーションを取得しています。コンフィグサーバによってロードされた設定の場所にあるベースapplication.ymlファイルには、次のものが含まれていますSpring Cloudコンフィグレーションサーバからコンフィグレーションを取得するとき、Springプロファイルが正しく順序付けされない

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} 

コンフィグサーバ(http://mygateway/config-server/myapp/test)のエンドポイントを打つとき、私が実行されている「myappの」アプリケーションのために、以下取り戻します"テスト" プロファイル:テストプロファイルでMyApp]を実行する場合

{ 
"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}" 

、eureka.client.service-url.defaultZoneの値は、予想外であり、http://instance1.localhost:7761/eureka,http://instance2.localhost:7762/eureka,http://instance3.localhost:7763/eurekaです。

私はテストプロファイルのエントリがそれを上書きすることを期待していました(ローカルにapplication.ymlを持っている場合と同じです)。 myAppの値を使用するときに、なぜ私が "テスト"プロファイルから値を取得しないのだろうか?

私の意図は、「デフォルト」の値を上部に追加し、「プロファイル」を非標準のデフォルト値より優先させることです。

更新: て、myApp/ENVがロードされ、「application.yml#テスト」を示していない、しかし、それはテストプロファイルを示しているが、デフォルト値のみが設定サーバ(ない#testもの)から戻さ:

{ 
    "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" 
+1

myApp '/ env'とは何ですか? – spencergibb

+0

上記の質問に答えるための追加情報を追加しました。大きな質問ですが、答えにつながる可能性があります。 – LetsBeFrank

答えて

1

完全なユーザーエラーでした。私は、環境変数またはbootstrap.ymlとして渡す代わりに、デフォルトの "test"アクティブなプロファイルをapplication.ymlに設定していました。そのため、設定サーバーのヒット時にすぐに読み込まれませんでした。

関連する問題