我正在尝试将我的微服务与Eureka连接起来。
我在主类中添加了注释@EnableDiscoveryClient
:
@EnableDiscoveryClient
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
我正在build.gradle
中使用下一个依赖项:
compile group: 'org.springframework.cloud', name: 'spring-cloud-netflix-eureka-client', version: '2.0.1.RELEASE'
最后,我已经将config添加到< code>application.yml中
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8761/eureka/
spring:
application.name: receipt-processing-microservice
正如你所暗示的,这是行不通的。在日志中,我没有看到任何带有标签< code>DiscoveryChannel或< code>Eureka的日志
将 application.yml 文件中的配置服务器端口更改为 8888。
server:
port: 8888
尝试启用调试日志。您将获得大量信息(您可以将其重定向到文件),并尝试查看下面发生的情况,特别是在容器启动之后以及发现客户端初始化时。在我的情况下,发现服务器运行在8061端口上,我的服务注册日志如下所示(请参阅指示服务向eureka服务器发送注册请求的日志)
DEBUG [employee-service,,,] Returning cached instance of singleton bean 'refreshEventListener'
DEBUG [employee-service,,,] Closing connections idle longer than 30000 SECONDS
DEBUG [employee-service,,,] Closing connections idle longer than 30000 SECONDS
INFO [employee-service,,,] Disable delta property : false
INFO [employee-service,,,] Single vip registry refresh property : null
INFO [employee-service,,,] Force full registry fetch : false
INFO [employee-service,,,] Application is null : false
INFO [employee-service,,,] Registered Applications size is zero : true
INFO [employee-service,,,] Application version is -1: false
INFO [employee-service,,,] Getting all instance registry info from the eureka server
Get connection: {}->http://localhost:8061, timeout = 5000
[{}->http://localhost:8061] total kept alive: 1, total issued: 0, total allocated: 1 out of 200
Getting free connection [{}->http://localhost:8061][null]
Stale connection check
CookieSpec selected: default
Auth cache not set in the context
Target auth state: UNCHALLENGED
Proxy auth state: UNCHALLENGED
Attempt 1 to execute request
Sending request: GET /eureka/apps/ HTTP/1.1
>> "GET /eureka/apps/ HTTP/1.1[\r][\n]"
>> "Accept: application/json[\r][\n]"
>> "DiscoveryIdentity-Name: DefaultClient[\r][\n]"
>> "DiscoveryIdentity-Version: 1.4[\r][\n]"
>> "DiscoveryIdentity-Id: 192.168.28.145[\r][\n]"
>> "Accept-Encoding: gzip[\r][\n]"
>> "Host: localhost:8061[\r][\n]"
>> "Connection: Keep-Alive[\r][\n]"
>> "User-Agent: Java-EurekaClient/v1.9.2[\r][\n]"
>> "[\r][\n]"
>> GET /eureka/apps/ HTTP/1.1
>> Accept: application/json
>> DiscoveryIdentity-Name: DefaultClient
>> DiscoveryIdentity-Version: 1.4
>> DiscoveryIdentity-Id: 192.168.28.145
>> Accept-Encoding: gzip
>> Host: localhost:8061
>> Connection: Keep-Alive
>> User-Agent: Java-EurekaClient/v1.9.2
Get connection: {}->http://localhost:8061, timeout = 5000
[{}->http://localhost:8061] total kept alive: 0, total issued: 1, total allocated: 1 out of 200
No free connections [{}->http://localhost:8061][null]
Available capacity: 49 out of 50 [{}->http://localhost:8061][null]
Creating new connection [{}->http://localhost:8061]
<< "HTTP/1.1 200 [\r][\n]"
<< "Content-Encoding: gzip[\r][\n]"
<< "Content-Type: application/json[\r][\n]"
<< "Content-Length: 549[\r][\n]"
<< "Date: Tue, 28 Aug 2018 06:48:14 GMT[\r][\n]"
<< "[\r][\n]"
Receiving response: HTTP/1.1 200
<< HTTP/1.1 200
<< Content-Encoding: gzip
<< Content-Type: application/json
<< Content-Length: 549
<< Date: Tue, 28 Aug 2018 06:48:14 GMT
Connection can be kept alive indefinitely
<< "[0x1f][0x8b][0x8][0x0][0x0][0x0][0x0][0x0][0x0][0x0][0x9d]S[0xd1][0x8e][0xda]0[0x10][0xfc][0x17][0xeb][0x1e]![0x10][0x8]4[0x97][0xa7];[0x91][0xa8][0x8a][0xda][0x3]D[0xca]UUU![0xd7]Y[0x88]U[0xc7][0x8e]l[0x87]k[0x84][0xf8][0xf7][0xae][0x93][0x86][0x96]SQ[0xd5]*[0xf][0x89]wg[0xd7];3[0x9b][0x13][0xa1]U%8[0xa3][0x96]+iHt"G[0xd0][0xc6]}[0xef]v9[0x8]KID|2p([0x8c][0x14][0xd4][0x14]L[0xe5][0x80][0xc1][0xed]z[0xe7][0xef][0xba]D_N[0xa2][0xcf]'"i[0xe9][0xd2][0xc9][0xd3][0xfa][0xfd][0xea]S[0x92][0xc][0xb3]d[0xf3][0x9c].[0x12]Dri,[0x95][0xc]ZXHs[0x4][0xa7][0x9b]4[0x1b].[0xb2][0xb7]C6[0xe3][0x95][0xa6]P%x[0x12]l[0x4]e%T[0x3]04[0xa0][0x8f][0x9c]A[0x14][0x8e][0xef][0xc7][0xd8][0xaa]P[0xc6].[0xbb][0x8b]n[0xd5]v[0xa3][0xdd][0x98][0xa4]z[0xcc]s[0xed][0x98][0xdd]O<[0x1e]z[0x93][0xd0][0xf3][0x83][0x19]fp([[0x9b][0x96][0x1e][0x9e][0x14]j[0xa1]y[0x9e][0x83][0xcc].[0xf1][0xe5][0xbb][0xe5][0xea][0xe3][0x12][0x93][0x95][0xd2][0xd6][0xe9]uG[0xda][0xa9][0x6][0xe4][0x1]$[0xfd]*[0xc0][0x11][0xb2][0xba][0x6]r[0xc6]v[0xc0]j[\r][0xeb]_[0xc8] [0x98]^[0x1][0xf7]T[0x98][0x16][0xc9]T-[0xad]n[0x9c][0x1c][0xfe][0x80][0xe4][0xd4][0xd2][0x5]H[0xb]:[0x95]{[0xe5]j[0x1f][0x98][0xa0][0xc6][\r][0xc0]T[0xe9][0xe8][0xed][0x5][0xff][0xee]!A[0x8e]y/[0xed][0xc5][0xc4][0xc3]][0xc]{Z[0xb][0x1b]_[0xb7][0x18][0xf4][0xc6]<5[0xab][0x17][0xe9]n[0x14]@[\r][0xf4][0xed]5Hx[0xa1]"u[0xf8][0xa3]{g[0xc0][0xf0][0xb6])[0xd2][0xca]k[0xdd][0xba][0xdb][0xc7][0x1c]U[\r][0x7]nl[0x17][0xff][0xc0]K[0xc0][0xeb]K[0xd4][0xda][0x9f]Mg[0xc1]4[0xc][0xe7][0xc1][0xc4][0xf][0xf1][0x6]j[0xec][0xa6]k|[0x1b][0x4][0xe8][0xeb][0xab]6c'\[0xeb][0xf7][0xb6][0xba]U[0x88][0x4]J[0xb0][0xd4][0x9][0xe5][0xe6]/[0xa9][0xa4][0x7]([0x91][0xaf][0xd7][0xf9]B[0xda]M9[0xbb]U)a[0x8d][0xb9][0xad][0x16][0x18]-[0xac][0xad][0xa2][0xd1][0xe8][0xe6][0xc2][0xb9][0xaa][0xd1]e[0xf][0xfe][0xb1][0x8e]2[S[0xab][0xf4][0x88]w[0x8a][0x17]@[0x85]-[0x16][0x5][0xb0]o[0xff][0xd3][0xa5]+[0xc7]>[0xc7]n_[0xa1][0xf5][0xff][0xf5]/A[0xfa]-{[0xfe][0xb][0x8a][0x9b][0x85]R:[0xe7][0x12]][0x93][0x87][0x98][0x1b][0xe6][0xd6][0xbb][0xc9][0x10][0x0][0xfa][0xb2][0x8a][0x9d]k[0xdb][\n]"
<< "[0x85][0x85][0xfc]7[0xf1][0xc9][0x95][0xfa]?a1[0xd7][0xb6][0xf9]3h<[\r][0xdc][0x1f][0xd8]Y[0xdb]Tn[0xf3][0x1e][0xe3]8[0x89][0xc9][0xf9][0xb]>[0xe7][0x1f][0xc1][0x8d][0x8f][0xd8]w[0x4][0x0][0x0]"
Connecting to localhost:8061
CookieSpec selected: default
Auth cache not set in the context
Target auth state: UNCHALLENGED
Proxy auth state: UNCHALLENGED
Attempt 1 to execute request
Sending request: PUT /eureka/apps/EMPLOYEE-SERVICE/aaaa-aaaa-1567.mshome.net:employee-service:8090?status=UP&lastDirtyTimestamp=1535438864034 HTTP/1.1
>> "PUT /eureka/apps/EMPLOYEE-SERVICE/aaaa-aaa-1567.mshome.net:employee-service:8090?status=UP&lastDirtyTimestamp=1535438864034 HTTP/1.1[\r][\n]"
>> "DiscoveryIdentity-Name: DefaultClient[\r][\n]"
>> "DiscoveryIdentity-Version: 1.4[\r][\n]"
>> "DiscoveryIdentity-Id: 192.168.28.145[\r][\n]"
>> "Accept-Encoding: gzip[\r][\n]"
>> "Content-Length: 0[\r][\n]"
>> "Host: localhost:8061[\r][\n]"
>> "Connection: Keep-Alive[\r][\n]"
>> "User-Agent: Java-EurekaClient/v1.9.2[\r][\n]"
>> "[\r][\n]"
>> PUT /eureka/apps/EMPLOYEE-SERVICE/aaaa-aaa-1567.mshome.net:employee-service:8090?status=UP&lastDirtyTimestamp=1535438864034 HTTP/1.1
>> DiscoveryIdentity-Name: DefaultClient
>> DiscoveryIdentity-Version: 1.4
>> DiscoveryIdentity-Id: 192.168.28.145
>> Accept-Encoding: gzip
>> Content-Length: 0
>> Host: localhost:8061
>> Connection: Keep-Alive
>> User-Agent: Java-EurekaClient/v1.9.2
<< "HTTP/1.1 200 [\r][\n]"
<< "Content-Type: application/xml[\r][\n]"
<< "Content-Length: 0[\r][\n]"
<< "Date: Tue, 28 Aug 2018 06:48:14 GMT[\r][\n]"
<< "[\r][\n]"
Receiving response: HTTP/1.1 200
<< HTTP/1.1 200
<< Content-Type: application/xml
<< Content-Length: 0
<< Date: Tue, 28 Aug 2018 06:48:14 GMT
Connection can be kept alive indefinitely
Released connection is reusable.
Releasing connection [{}->http://localhost:8061][null]
Pooling connection [{}->http://localhost:8061][null]; keep alive indefinitely
Notifying no-one, there are no waiting threads
Jersey HTTP PUT http://localhost:8061/eureka//apps/EMPLOYEE-SERVICE/aaa-aaa-1567.mshome.net:employee-service:8090; statusCode=200
DiscoveryClient_EMPLOYEE-SERVICE/aaaa-aaa-1567.mshome.net:employee-service:8090 - Heartbeat status: 200
也许您缺少部分配置?
我有以下和一切工作完美:
#Eureka configuration
eureka.client.enabled=true
eureka.client.serviceUrl.defaultZone=${EUREKA_SERVICE_URL:http://admin:admin@localhost:7995}/eureka/
eureka.client.healthcheck.enabled=true
eureka.client.registerWithEureka=true
eureka.client.fetchRegistry=true
eureka.instance.leaseRenewalIntervalInSeconds=15
eureka.instance.leaseExpirationDurationInSeconds=30
你可以用更多的参数来尝试一下,看看会发生什么。
另外,请检查尤里卡 web-ui 中的服务列表,以防它只是一个控制台日志问题:请参阅 localhost:8761/# 。
我正在尝试向尤里卡服务器注册我的微服务。但它显示浏览器中没有可用的实例。我在控制台中没有收到任何错误。请帮助我解决这个问题。 我已经通过在谷歌上搜索尝试了多个选项。不过,我无法解决此问题。 微服务应用程序.属性 客户端主类 Eureka服务器application.properties 尤里卡服务器主类。
我正在尝试使用Spring和Spring Boot学习微服务,并学习部署到云平台。我计划创建一个Angular 2前端应用程序,它与我部署的微服务进行通信。现在,我正在浏览Spring cloud services Eureka、Zuul、Recural breakers等。 null
我刚刚开始通过Spring Cloud了解微服务,首先我尝试从本文中重现基本示例https://spring.io/blog/2015/07/14/microservices-with-spring.这是我的代码: 尤里卡服务器 资源/registration-server.yml: 示例服务: 帐户-服务. yml: 你能打电话给我,请问我做错了什么吗? 编辑
我尝试将我的服务(auth-service)连接到service Registry的Eureka服务器。Eureka服务器正在运行,但当我尝试连接身份验证服务时,什么也没有发生。 Eureka服务器的URL:http://localhost:8761/ DS副本:本地主机 启动身份验证服务时的消息: 发现服务pom
我有一个Spring Boot微服务项目,用三个微服务来测试分布式事务管理的saga模式。 当我使用 命令后,微服务无法连接到Axon服务器,我收到了以下错误: 我的问题是为什么微服务在中寻找axon服务器,这显然是错误的,并且违反了它们在中的配置: 这里的轴子服务器的容器名称。
我正在使用spring boot和netflix OSS在微服务中创建一个简单的项目来弄脏我的手。我创建了两个服务 配置服务,它必须在发现(尤里卡)服务中注册自己。 发现服务,需要配置服务运行才能获得其配置。