Spring boot Eureka客户端异常com.netflix.discovery.shared.transport.TransportException:无法在任何已知服务器上执行请求
我不熟悉微服务。我正在尝试创建一个用于学习的小应用程序。这是我的密码: EurekaServer-application.ymlSpring boot Eureka客户端异常com.netflix.discovery.shared.transport.TransportException:无法在任何已知服务器上执行请求,spring-boot,microservices,spring-cloud,netflix-eureka,Spring Boot,Microservices,Spring Cloud,Netflix Eureka,我不熟悉微服务。我正在尝试创建一个用于学习的小应用程序。这是我的密码: EurekaServer-application.yml spring: application: name: EurekaServer server: port: 8080 servlet: context-path: /EurekaServer eureka: client: fetch-registry: false
spring:
application:
name: EurekaServer
server:
port: 8080
servlet:
context-path: /EurekaServer
eureka:
client:
fetch-registry: false
register-with-eureka: false
defaultZone: http://localhost:8080/EurekaServer/eureka
Eureka服务器工作正常,我可以在
EmployeeClient:application.yml如下:
spring:
application:
name: EmployeeClient
server:
port: 8586
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8080/EurekaServer
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<spring-cloud.version>Finchley.RELEASE</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
<dependency>
在最后一行中,我需要显式地编写serviceUrl,因为在sts中按ctrl+space时,它不显示选项serviceUrl,而是显示服务url,连字符符号。defaultZone也是如此。我是否缺少一些jar或特定版本
My EmployeeClientApplication.java
@EnableEurekaClient
@SpringBootApplication
public class EmployeeClientApplication {
public static void main(String[] args) {
SpringApplication.run(EmployeeClientApplication.class, args);
}
}
当我尝试运行EmployeeClientApplication.java时,会出现以下异常:
com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known server
我还尝试使用@EnableDiscoveryClient代替@EnableEurekClient,但没有成功
EmployeeClient pom.xml的一部分如下:
spring:
application:
name: EmployeeClient
server:
port: 8586
eureka:
client:
serviceUrl:
defaultZone: http://localhost:8080/EurekaServer
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
<spring-cloud.version>Finchley.RELEASE</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
<dependency>
我犯了什么错误?我认为,您必须将客户端属性中的默认区域从/EurekaServer更改为/eureka /eureka是向eureka注册表注册服务的rest端点。 进行更改并尝试,它应该会起作用
除此之外,如果您愿意更改UI仪表板url,则应使用eureka.dashboard.path属性。我认为,您必须将客户端属性中的默认区域从/EurekaServer更改为/eureka /eureka是向eureka注册表注册服务的rest端点。 进行更改并尝试,它应该会起作用
除此之外,如果您愿意更改UI仪表板url,则应使用eureka.dashboard.path属性。我必须使用EmployeeClient application.yml中的以下行
spring:
application:
name: EurekaServer
server:
port: 8080
servlet:
context-path: /EurekaServer
eureka:
client:
fetch-registry: false
register-with-eureka: false
defaultZone: http://localhost:8080/EurekaServer/eureka
我必须在EmployeeClient application.yml中使用下线
spring:
application:
name: EurekaServer
server:
port: 8080
servlet:
context-path: /EurekaServer
eureka:
client:
fetch-registry: false
register-with-eureka: false
defaultZone: http://localhost:8080/EurekaServer/eureka
添加eureka.instance.hostname=localhost可以解决您的问题,如果您在服务器的应用程序属性文件中添加了DiscoveryServer作为应用程序名称。添加eureka.instance.hostname=localhost可以解决您的问题,如果您在服务器的应用程序属性文件中添加了DiscoveryServer作为应用程序名称。是,你的回答有一半是正确的,这给了我一个想法。我在下面回答+谢谢你的回答。谢谢,伙计。是的,你的回答有一半是正确的,这给了我一个想法。我在下面回答+谢谢你的回答。谢谢,伙计。你可以在下面查看我的答案。我已经添加了该属性,但是得到了上面给出的错误!你可以在下面查看我的答案。我已经添加了该属性,但是得到了上面给出的错误!