因此,当我运行服务实例时。它不会将自己注册到发现服务器。而且没有错误,因此在这里我无法确定问题。

我的服务的application.properties看起来像这样,发现服务器的application.properties可以在所附的屏幕截图中看到。

spring.application.name = service
eureka.client.service-url.defaultZone =http://localhost:8761/eureka/

localhost:8761的Eureka仪表板显示该服务没有可用的实例。

java - 无法将服务注册到发现服务器(EUREKA)-LMLPHP

最佳答案

您必须在pom.xml中添加此依赖项,这将使您的服务保持正常运行:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-web</artifactId>
</dependency>

此外,我认为您应该为Eureka默认区域部分重构application.properties文件,如下所示:
eureka.client.serviceUrl.defaultZone=http://localhost:8761/eureka/
eureka.instance.preferIpAddress=true
eureka.client.registerWithEureka=true
eureka.client.fetchRegistry=true

07-28 13:30