当前位置: 首页 > 知识库问答 >
问题:

PCF Dev上无法访问Eureka客户端服务

朱慈
2023-03-14

这是我使用PCF开发的第一个微服务。我创建了以下Eureka服务器应用程序。

@EnableEurekaServer
@SpringBootApplication
public class EurekaServiceApplication {

    public static void main(String[] args) {
        SpringApplication.run(EurekaServiceApplication.class, args);
    }
}

以下是eureka服务器服务的属性

eureka-service.register-with-eureka=false
eureka-service.fetch-registry=false
eureka-service.defaultZone=http://eureka-service.local.pcfdev.io/
eureka-service.logging.level.com.netflix.eureka=OFF
eureka-service.logging.level.com.netflix.discovery=OFF

以下是eureka客户服务

@EnableDiscoveryClient
@SpringBootApplication
public class EurekaClientApplication {

    public static void main(String[] args) {
        SpringApplication.run(EurekaClientApplication.class, args);
    }
}

@RestController
class ServiceInstanceRestController {

    @Autowired
    private DiscoveryClient discoveryClient;

    @RequestMapping("/service-instances/{applicationName}")
    public List<ServiceInstance> serviceInstancesByApplicationName(@PathVariable String applicationName) {
        return this.discoveryClient.getInstances(applicationName);
    }
}

以下是eureka客户端服务的属性

eureka.client.register-with-eureka=true
eureka.client.fetch-registry=true
eureka.client.defaultZone=http://eureka-client.local.pcfdev.io/
eureka.client.logging.level.com.netflix.eureka=ON
eureka.client.logging.level.com.netflix.discovery=ON

我已经在本地服务器上运行的PCF Dev实例上部署了微服务

当我运行服务器时

http://eureka-client.local.pcfdev.io/service-instances/eureka-client

当我试图访问尤里卡服务时,使用网址

http://eureka-service.local.pcfdev.io/

我得到以下回应:

This site can’t be reached eureka-service.local.pcfdev.io refused to connect.
Search Google for eureka service local pcfdev io
ERR_CONNECTION_REFUSED

提前感谢。

编辑-1:

根据@Barath的评论,我修改了客户端应用程序的application.properties文件,如下所示,但问题仍未解决。之前,我错误地引用了application.properties文件中的客户端应用程序名称。

eureka-client.register-with-eureka=true
eureka-client.fetch-registry=true
eureka-client.serviceUrl.defaultZone=http://eureka-client.local.pcfdev.io/
eureka-client.logging.level.com.netflix.eureka=ON
eureka-client.logging.level.com.netflix.discovery=ON

引导程序。客户端的属性文件具有以下条目:

spring.application.name=eureka-client 

引导程序。服务器的属性文件具有以下条目:

spring.application.name=eureka-service

编辑-2

服务器:https://github.com/abnig/eureka-service客户:https://github.com/abnig/eureka-client

共有1个答案

曹超
2023-03-14

eureka服务器和客户端中定义的属性描述如下

尤里卡服务器

eureka:
  instance:
    hostname: eureka-service.local.pcfdev.io
  client:
    fetch-registry: false
    register-with-eureka: false

尤里卡-客户

eureka:
  client:
    serviceUrl:
      defaultZone: https://eureka-service.local.pcfdev.io/eureka
    register-with-eureka: true
    fetch-registry: true

请参考SpringCloudNative

 类似资料:
  • 我正在使用spring、spring boot、eureka(用于服务发现)和ribbon开发一个微服务应用程序。 我的应用程序由三个服务组成:客户端、服务器和eureka服务器 客户端和服务器都在eureka服务器上注册,之后客户端使用eureka服务发现调用服务器。 我可以在本地运行应用程序,一切都很好。 但是当部署在aws上时,事情就会失控。 接下来的步骤 同一安全组中有三个ec2实例 每个

  • pom.xml 主应用程序类 Application.Properties eureka客户端设置 pom.xml Application.Properties 我在eureka-server仪表板(http://localhost:8761)中没有看到向Eureka server注册的micro-service-currency-exchange-service 为什么eureka客户端没有注册

  • 服务发现是基于微服务架构的关键原则之一。尝试配置每个客户端或某种形式的约定可能非常困难,可以非常脆弱。Netflix服务发现服务器和客户端是Eureka。可以将服务器配置和部署为高可用性,每个服务器将注册服务的状态复制到其他服务器。 如何包含Eureka客户端 要在您的项目中包含Eureka客户端,请使用组org.springframework.cloud和工件ID spring-cloud-st

  • 我对docker,Spring框架的一切都很陌生…它们成功地在localhost环境中运行,现在我想把它们推送到docker中,但是总是给我错误,我在那里卡住了大约一周。有人能帮我弄清楚吗!!! 现在我有 eureka 服务器和云配置服务器服务,这是我的代码: 尤里卡服务器应用程序.yml 和 Dockerfile: 现在我有云配置服务器应用程序.yml:在这个文件中,我试图在github上备份它

  • 24.10 在客户端访问RESTful服务 RestTemplate是客户端访问RESTful服务的核心类。它在概念上类似于Spring中的其他模板类,例如JdbcTemplate、 JmsTemplate和其他Spring组合项目中发现的其他模板类。 RestTemplate’s behavior is customized by providing callback methods and c