无法在任何已知的服务器eureka上执行请求

zd287kbt  于 2021-07-23  发布在  Java
关注(0)|答案(1)|浏览(424)

我使用eureka客户端和eureka服务器,但在启动eureka时收到错误“com.netflix.discovery.shared.transport.transportexception:无法在任何已知服务器上执行请求”。我没有和使用一个安全层的Eureka 。我的问题是“spring.cloud.version”。我读过这篇文章https://spring.io/blog/2020/12/15/spring-cloud-2020-0-0-rc1-aka-ilford-is-availablefor pom.xml的配置。
EUREKAA应用程序

@SpringBootApplication
@EnableEurekaServer
public class EurekaApplication {

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

}

pom.xml文件

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.4.2</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.eureka</groupId>
    <artifactId>eureka</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>eureka</name>
    <description>eureka</description>
    <properties>
        <java.version>1.8</java.version>
        <spring-cloud.version>2020.0.0-RC1</spring-cloud.version>
    </properties>
    <dependencies>
        <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-server</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${spring-cloud.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
    <repositories>
        <repository>
            <id>spring-milestones</id>
            <name>Spring Milestones</name>
            <url>https://repo.spring.io/milestone</url>
        </repository>
    </repositories>

</project>

bootstrap.properties属性

spring.application.name=eureka

spring.cloud.config.uri=http://localhost:9101

eureka.client.register-with-eureka=false

eureka.client.fetch-registry=false

Eureka 地产

server.port=9102
spring.application.name: eureka
eureka.client.serviceUrl.defaultZone: http://localhost:9102/eureka/
eureka.client.registerWithEureka=false
eureka.client.fetchRegistry=false
icomxhvb

icomxhvb1#

如果我没弄错的话,你的 eureka.properties 应该是:

server.port = 9102
spring.application.name = eureka
eureka.client.serviceUrl.defaultZone = http://localhost:9102/eureka/
eureka.client.register-with-eureka = false
eureka.client.fetch-registry = false

在你的 EurekaApplication 添加以下内容,以便serviceregistry将自动注册本地服务器。

@EnableDiscoveryClient

相关问题