0
自分でEurekaサーバーをローカルにセットアップして問題なくサービスを登録できますが、Pivotal Cloud Foundryの「サービスレジストリ」サービスを使用してEurekaサーバーを作成すると、アプリケーションが「登録済みアプリケーション」の下に表示されません。Cloud Foundry Service Registry(Netflix Eureka)サービスを使用するためのSpringブート設定とは何ですか?
私は次のことをやった:
- クラウドファウンドリー市場を経由してサービスのレジストリを作成しました。
- 私のアプリケーションをサービスにバインドしました。
- 私のアプリケーションをサービスに登録しました。
ログ:
2017-03-25T11:32:26.994-04:00 [APP/PROC/WEB/0] [OUT] 2017-03-25 15:32:26.994 INFO 13 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Located managed bean 'refreshEndpoint': registering with JMX server as MBean [org.springframework.cloud.endpoint:name=refreshEndpoint,type=RefreshEndpoint]
2017-03-25T11:32:27.426-04:00 [APP/PROC/WEB/0] [OUT] 2017-03-25 15:32:27.424 INFO 13 --- [ main] o.s.c.support.DefaultLifecycleProcessor : Starting beans in phase 0
2017-03-25T11:32:27.444-04:00 [APP/PROC/WEB/0] [OUT] 2017-03-25 15:32:27.443 INFO 13 --- [ main] o.s.c.n.eureka.InstanceInfoFactory : Setting initial instance status as: STARTING
2017-03-25T11:32:27.758-04:00 [APP/PROC/WEB/0] [OUT] 2017-03-25 15:32:27.755 INFO 13 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON encoding codec LegacyJacksonJson
2017-03-25T11:32:27.758-04:00 [APP/PROC/WEB/0] [OUT] 2017-03-25 15:32:27.758 INFO 13 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON decoding codec LegacyJacksonJson
2017-03-25T11:32:28.114-04:00 [APP/PROC/WEB/0] [OUT] 2017-03-25 15:32:28.113 INFO 13 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML decoding codec XStreamXml
2017-03-25T11:32:28.114-04:00 [APP/PROC/WEB/0] [OUT] 2017-03-25 15:32:28.113 INFO 13 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML encoding codec XStreamXml
2017-03-25T11:32:28.682-04:00 [APP/PROC/WEB/0] [OUT] 2017-03-25 15:32:28.678 INFO 13 --- [ main] c.n.d.s.r.aws.ConfigClusterResolver : Resolving eureka endpoints via configuration
2017-03-25T11:32:28.745-04:00 [APP/PROC/WEB/0] [OUT] 2017-03-25 15:32:28.745 INFO 13 --- [ main] com.netflix.discovery.DiscoveryClient : Disable delta property : false
2017-03-25T11:32:28.745-04:00 [APP/PROC/WEB/0] [OUT] 2017-03-25 15:32:28.745 INFO 13 --- [ main] com.netflix.discovery.DiscoveryClient : Single vip registry refresh property : null
2017-03-25T11:32:28.745-04:00 [APP/PROC/WEB/0] [OUT] 2017-03-25 15:32:28.745 INFO 13 --- [ main] com.netflix.discovery.DiscoveryClient : Force full registry fetch : false
2017-03-25T11:32:28.746-04:00 [APP/PROC/WEB/0] [OUT] 2017-03-25 15:32:28.745 INFO 13 --- [ main] com.netflix.discovery.DiscoveryClient : Application is null : false
2017-03-25T11:32:28.746-04:00 [APP/PROC/WEB/0] [OUT] 2017-03-25 15:32:28.745 INFO 13 --- [ main] com.netflix.discovery.DiscoveryClient : Registered Applications size is zero : true
2017-03-25T11:32:28.747-04:00 [APP/PROC/WEB/0] [OUT] 2017-03-25 15:32:28.745 INFO 13 --- [ main] com.netflix.discovery.DiscoveryClient : Application version is -1: true
2017-03-25T11:32:28.761-04:00 [APP/PROC/WEB/0] [OUT] 2017-03-25 15:32:28.747 INFO 13 --- [ main] com.netflix.discovery.DiscoveryClient : Getting all instance registry info from the eureka server
2017-03-25T11:32:29.156-04:00 [APP/PROC/WEB/0] [OUT] 2017-03-25 15:32:29.155 INFO 13 --- [ main] com.netflix.discovery.DiscoveryClient : The response status is 200
2017-03-25T11:32:29.160-04:00 [APP/PROC/WEB/0] [OUT] 2017-03-25 15:32:29.160 INFO 13 --- [ main] com.netflix.discovery.DiscoveryClient : Starting heartbeat executor: renew interval is: 30
2017-03-25T11:32:29.165-04:00 [APP/PROC/WEB/0] [OUT] 2017-03-25 15:32:29.164 INFO 13 --- [ main] c.n.discovery.InstanceInfoReplicator : InstanceInfoReplicator onDemand update allowed rate per min is 4
2017-03-25T11:32:29.170-04:00 [APP/PROC/WEB/0] [OUT] 2017-03-25 15:32:29.169 INFO 13 --- [ main] com.netflix.discovery.DiscoveryClient : Discovery Client initialized at timestamp 1490455949169 with initial instances count: 23
2017-03-25T11:32:29.227-04:00 [APP/PROC/WEB/0] [OUT] 2017-03-25 15:32:29.227 INFO 13 --- [ main] c.n.e.EurekaDiscoveryClientConfiguration : Registering application gym-service with eureka with status UP
2017-03-25T11:32:29.230-04:00 [APP/PROC/WEB/0] [OUT] 2017-03-25 15:32:29.229 INFO 13 --- [ main] com.netflix.discovery.DiscoveryClient : Saw local status change event StatusChangeEvent [timestamp=1490455949229, current=UP, previous=STARTING]
2017-03-25T11:32:29.236-04:00 [APP/PROC/WEB/0] [OUT] 2017-03-25 15:32:29.236 INFO 13 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_GYM-SERVICE/3a2f6286-096c-4a2a-782a-03bab8f020a9: registering service...
2017-03-25T11:32:29.349-04:00 [APP/PROC/WEB/0] [OUT] 2017-03-25 15:32:29.348 INFO 13 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_GYM-SERVICE/3a2f6286-096c-4a2a-782a-03bab8f020a9 - registration status: 204
2017-03-25T11:32:29.570-04:00 [APP/PROC/WEB/0] [OUT] 2017-03-25 15:32:29.569 INFO 13 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http)
2017-03-25T11:32:29.575-04:00 [APP/PROC/WEB/0] [OUT] 2017-03-25 15:32:29.574 INFO 13 --- [ main] c.n.e.EurekaDiscoveryClientConfiguration : Updating port to 8080
2017-03-25T11:32:29.582-04:00 [APP/PROC/WEB/0] [OUT] 2017-03-25 15:32:29.582 INFO 13 --- [ main] com.campbellonsoftware.orka.GymServer : Started GymServer in 22.159 seconds (JVM running for 24.923)
2017-03-25T11:32:31.135-04:00 [CELL/0] [OUT] Container became healthy
2017-03-25T11:37:28.751-04:00 [APP/PROC/WEB/0] [OUT] 2017-03-25 15:37:28.751 INFO 13 --- [trap-executor-0] c.n.d.s.r.aws.ConfigClusterResolver : Resolving eureka endpoints via configuration
管理-gym.ymlファイル:
# Spring properties
spring:
application:
name: gym-service # Service registers under this name
freemarker:
enabled: false # Ignore Eureka dashboard FreeMarker templates
thymeleaf:
cache: false # Allow Thymeleaf templates to be reloaded at runtime
prefix: classpath:/manage-gym/templates/ # Trailing/mandatory
# Template location for this application only
# Map the error path to error template (for Thymeleaf)
error:
path: /error
# HTTP Server
server:
port: 2222 # HTTP (Tomcat) port
# Discovery Server Access
# 1. DEV ONLY: Reduce the lease renewal interval to speed up registration
# 2. Define URL of registration server (defaultZone)
eureka:
client:
serviceUrl:
defaultZone: ${vcap.services.${PREFIX:}eureka.credentials.uri:http://user:${eureka.password:}@${PREFIX:}eureka.${application.domain:cfapps.io}}/eureka/
instance:
hostname: ${vcap.application.uris[0]}
leaseRenewalIntervalInSeconds: 30 # DO NOT DO THIS IN PRODUCTION
メインクラス:
package com.campbellonsoftware.orka;
import java.util.logging.Logger;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
@SpringBootApplication
@EnableAutoConfiguration
@EnableDiscoveryClient
public class GymServer {
protected Logger logger = Logger.getLogger(GymServer.class.getName());
public static void main(String[] args) {
System.setProperty("spring.config.name", "manage-gym");
SpringApplication.run(GymServer.class, args);
}
}
ピボタルCFに春のクラウドサービスが提供するサービスのレジストリが事前に設定ユーレカですが、SCSは、セキュリティにISNの層を提供します」オープンソースのSpring Cloudで提供されています。詳細はこちら:http://docs.pivotal.io/spring-cloud-services/1-3/common/security-overview.html#service-registry-service-instances見つけて追加した依存関係は、クライアントアプリケーションがこのセキュリティをネゴシエートするのに役立ちます。適切なOAuth設定であなたのアプリケーションで自分でそれを行うことができますが、 'spring-cloud-services-starter-service-registry' libはそれをすべて行います。 –
お役立ち情報ありがとうScott –