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

Eureka Client Service not reachable on PCF Dev

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

@EnableEurekaServer
@SpringBootApplication
public class EurekaServiceApplication {

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

以下是 eureka-server 服务的属性

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-client服务

@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-client 服务的属性

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

我已经在本地 运行ning 上的 PCF 开发实例上部署了微服务

当我在本地 运行 服务器和客户端作为 Java 应用程序时,我可以看到来自 service-instances/eureka-client 的响应端点。但是当我尝试调用以下端点时我得到一个空数组

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

当我尝试访问 eureka 服务时,使用 URL

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

客户端的 bootstrap.properties 文件具有以下条目:

spring.application.name=eureka-client 

服务器的 bootstrap.properties 文件具有以下条目:

spring.application.name=eureka-service

Edit-2

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

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

请参考spring-cloud-native参考