提供されているPWS(Pivotal Web Services)に接続するSpringブートアプリケーションを構成するのに苦労していますSpring-Cloud - コネクタ。コンフィギュレーションサーバが正しく対応し、VCAP_SERVICESエントリによって反射されたアプリケーションにバインドさmanifest.ymlでPWS Config-Serverを使用するためにSpring-Cloud-ConnectorでSpringブートを構成する
:
applications:
- name: edge-service-webapp-myapp
services:
- infrastructure-config-server
memory: 512M
env:
TRUST_CERTS: api.run.pivotal.io
SPRING_PROFILES_DEFAULT: cloud
instances: 1
host: edge-service-webapp-myapp
domain: cfapps.io
buildpack: java_buildpack
{
"VCAP_SERVICES": {
"p-config-server": [
{
"credentials": {
"access_token_uri": "https://p-spring-cloud-services.uaa.run.pivotal.io/oauth/token",
"client_id": "p-config-server-84d66ea6-ebc6-xxx",
"client_secret": "***",
"uri": "https://config-b4320676-xxx.cfapps.io"
}, ...
}
アプリケーションは、ばねブートスタータ親1.5で構築されます。 2.RELEASE、spring-cloud-dependencies Camden.SR5およびspring-cloud-services-dependencies 1.4.1.RELEASE。また、明示的な依存関係としてspring-cloud-starter-configとspring-boot-starter-cloud-connectorsを使用しています。
<dependencyManagement>
<dependencies>
<dependency>
<groupId>io.pivotal.spring.cloud</groupId>
<artifactId>spring-cloud-services-dependencies</artifactId>
<version>1.4.1.RELEASE</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Camden.SR5</version>
<type>pom</type>
<scope>import</scope>
</dependency>
....
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-cloud-connectors</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
...
私はコンフィグサーバをカールするとき、私はアプリケーション名(私のアプリ)とアクティブ」クラウドのプロファイルで利用可能なアプリケーションのバージョンを見ることができます。
spring:
application:
name: my-app
cloud:
config:
enabled: true
curl -H "Authorization: Bearer XXX" https://config-b4320676-xxx.cfapps.io/tradefoundry/cloud
{"name":"my-app","profiles":["cloud"],"label":"master","version":"389e4f909ff1303332167b2159b4d75201109d69","state":null,"propertySources":[{"name":"https://gitlab.com/myapp/configuration.git/myapp-cloud.properties","source":{"spring.thymeleaf.cache":"true","message":"Hello Cloud!"}},{"name":"https://gitlab.com/myapp/configuration.git/myapp.properties","source":{"server.compression.enabled":"true","spring.thymeleaf.cache":"true","application.version":"0.0.1"}},{"name":"https://gitlab.com/myapp/configuration.git/application.properties","source":{"server.compression.enabled":"true","spring.thymeleaf.cache":"true","application.cache.busting.enabled":"false","application.version":"0.0.1-20170202195700","server.compression.mime-types":"application/json,application/xml,text/html,text/xml,text/plain,text/css,application/javascript"}}]}
しかし、まだアプリケーションが不足しているプロパティapplication.version不満、起動時に失敗しました。
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'myWebappApplication': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'application.version' in value "${application.version}"
私はここで何が欠けていますか?私は雲のコネクタがすべて自動設定によるプラグアンドプレイであると思った!
何か助けてください!
あなたは私の日を救った! ...そして今私はドキュメントのその部分をスキップするためにちょっと愚かな気がします...お粗末な私... – achingfingers
ドキュメントは素晴らしいです - 一度あなたは彼らが存在し、彼らがどこに住んでいるかを知ってください。これらは見つけるのが最も簡単な文書ではないかもしれません。あなたの問題を解決したと聞いてうれしいです。 –