这是我第一次使用PCF开发的微型服务。我已经创建了以下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客户端服务。
@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实例上部署了微服务。

当我将服务器&客户机作为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编辑-2
服务器:https://github.com/abnig/eureka-service客户端:https://github.com/abnig/eureka-client
发布于 2018-10-20 19:23:11
在eureka服务器和客户端中定义的属性如下所示
eureka-服务器
eureka:
instance:
hostname: eureka-service.local.pcfdev.io
client:
fetch-registry: false
register-with-eureka: falseeureka-客户机
eureka:
client:
serviceUrl:
defaultZone: https://eureka-service.local.pcfdev.io/eureka
register-with-eureka: true
fetch-registry: true请参考春云
https://stackoverflow.com/questions/52907768
复制相似问题