eureka client为什么不能成功注册到server

我的情况是client的dependency写错了。
当前是这样的:

<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.codejam</groupId>
    <artifactId>eurekaClient</artifactId>
    <version>1.0-SNAPSHOT</version>

   <parent>

       <groupId>org.springframework.boot</groupId>
       <artifactId>spring-boot-starter-parent</artifactId>
       <version>LATEST</version>
   </parent>

    <dependencies>


        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
            <version>LATEST</version>
        </dependency>
    </dependencies>

</project>

注意其中

spring-cloud-starter-netflix-eureka-server

不要写成了

spring-cloud-netflix-eureka-server

完毕。


另外,启动类是这样的:

package com.codejam.eureka.client;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
 * @author zhaosen
 * @date 3/6/2020
 */
@SpringBootApplication
public class EurekaClientApplication {
    public static void main(String[] args) {
        SpringApplication.run(EurekaClientApplication.class, args);
    }
}

然后就成功了啊。

在这里插入图片描述

发布了181 篇原创文章 · 获赞 54 · 访问量 45万+

猜你喜欢

转载自blog.csdn.net/festone000/article/details/104688964