私はコンサルの最初のセットアップを使用しています。このため、私は8500にマップされたポート8500の領事ドッカー画像を使用していますので、ローカルセットアップで正常に使用できます。http://localhost:8500で領事にアクセスできます。 コンサルの最初の設定で構成サーバーが検出されない
I持って 設定サーバーの次の構成 - のpom.xml<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-config-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-discovery</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Dalston.RC1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
Application.yml
server:
port: 8888
spring:
cloud:
config:
server:
git:
uri: https://github.com/xxxxxx/spring-config-repo.git
consul:
host: consul
port: 8500
enabled: true
discovery:
enabled: true
register: true
service-name: configservice
bootstrap.yml
spring:
application:
name: config-server
ConfigServerApplication.java
@EnableConfigServer
@EnableDiscoveryClient
@SpringBootApplication
public class ConfigServiceApplication {
public static void main(String[] args) {
SpringApplication.run(ConfigServiceApplication.class, args);
}
}
私は、このjarファイルを実行すると、それが成功しています。私はCONUULでconfigサーバを見ることができます。 consul-
Request - http://localhost:8500/v1/catalog/services
Response -
{
"configservice": [],
"consul": []
}
Request - http://localhost:8500/v1/catalog/service/configservice
Response -
[
{
"ID": "f6ac953c-07b9-4097-974e-3ea9cd39bec2",
"Node": "a0954c644062",
"Address": "127.0.0.1",
"TaggedAddresses": {
"lan": "127.0.0.1",
"wan": "127.0.0.1"
},
"NodeMeta": {},
"ServiceID": "config-server-8888",
"ServiceName": "configservice",
"ServiceTags": [],
"ServiceAddress": "10.0.0.158",
"ServicePort": 8888,
"ServiceEnableTagOverride": false,
"CreateIndex": 15,
"ModifyIndex": 15
}
]
から見た後 は、私はコンフィグサーバからプロパティを使用するクライアントアプリケーションを持って、私もこのuri-
http://localhost:8888/configclient/default
を使用してコンフィグサーバにアクセスできる設定サーバーの詳細です私の理解は、このjarを実行すると、consulに連絡してそこから設定サーバー情報を取得し、指定されたgit uriからプロパティを取得してプロパティを設定するということです。続き
は、クライアントの詳細です - のpom.xml
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-consul-all</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>Dalston.RC1</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
bootstrap.yml
spring:
application:
name: myservice
cloud:
config:
fail-fast: true
retry:
max-attempts: 20
initial-interval: 3000
enabled: true
discovery:
enabled: true
service-id: configserver
consul:
host: localhost
port: 8500
discovery:
enabled: true
register: true
service-name: myservice
application.yml
server:
port: 8081
MyServiceApplication.java
@EnableDiscoveryClient
@SpringBootApplication
public class MyServiceApplication {
public static void main(String[] args) {
SpringApplication.run(ApplePaymentServiceApplication.class, args);
}
}
しかし、この瓶のこの起動時に、そのコンフィグサーバを検索し、代わりにバックデフォルトのURIに落下することはできません。 は、これは私が、このような consul first bootstrap with spring cloud config
など様々な例からさまざまなオプションの多くに手を加え、関連する起動ログセクション
2017-03-28 00:40:20.407 WARN 99123 --- [ main] lientConfigServiceBootstrapConfiguration : No instances found of configserver (configserver)
2017-03-28 00:40:20.551 INFO 99123 --- [ main] b.c.PropertySourceBootstrapConfiguration : Located property source: CompositePropertySource [name='consul', propertySources= . [ConsulPropertySource [name='config/myservice/'], ConsulPropertySource [name='config/application/']]]
2017-03-28 00:40:20.587 INFO 99123 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at: http://localhost:8888
2017-03-28 00:40:21.831 INFO 99123 --- [ main] c.c.c.ConfigServicePropertySourceLocator : Located environment: name=myservice, profiles=[default], label=null, version=null, state=null
2017-03-28 00:40:21.832 INFO 99123 --- [ main] b.c.PropertySourceBootstrapConfiguration : Located property source: CompositePropertySource [name='configService', propertySources=[MapPropertySource [name='https://github.com/xxxxx/spring-config-repo.git/myservice.yml'], MapPropertySource [name='https://github.com/xxxxx/spring-config-repo.git/application.yml']]]
2017-03-28 00:40:21.841 INFO 99123 --- [ main] c.h.MyServiceApplication : No active profile set, falling back to default profiles: default
で誰かが私が行方不明かもしれないものを指すことができますか? consul、configserver、およびclientのための適切なアプリケーション/ブートストラップファイルにアクセスできる実用的な例へのポインタが最も役立ちます。
PS:質問の情報オーバーロードについてお詫び申し上げます。それの中には関連性がないものもありますが、できるだけ多くの情報を提供して、誰かが以前に遭遇したことを発見できるようにしたいと考えていました。
ありがとうスペンサー。私はかなり微妙にやりましたが、そのミスマッチはどのように名前に残っていて、それに気付かなかったものもあります。私は今、うまく動作します。 – Somnath
答えを受け入れるのはいかがですか – spencergibb
私は持っていると思います。私はチェックマークを緑色に切り替えるといいと思います。それはソリューションが機能した後の最初のことでした。:)それ以外は何もしなくてはなりませんか? – Somnath