1、直入主题,导入pom文件

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">

4.0.0

org.springframework.boot

spring-boot-starter-parent

2.3.9.RELEASE

com.example

eureka

0.0.1-SNAPSHOT

8

8

UTF-8

org.springframework.cloud

spring-cloud-dependencies

Hoxton.SR12

pom

import

org.springframework.boot

spring-boot-starter-web

org.springframework.cloud

spring-cloud-starter-eureka-server

1.4.4.RELEASE

2、application.yml文件

server:

port: 9111

eureka:

instance:

hostname: localhost # eureka所在的服务器名

client:

fetch-registry: false

register-with-eureka: false

# eureka提供服务的地址

service-url:

defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka

3、启动类

package com.xxx;

import org.springframework.boot.SpringApplication;

import org.springframework.boot.autoconfigure.SpringBootApplication;

import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;

@EnableEurekaServer

@SpringBootApplication

public class EurekaApplication {

public static void main(String[] args) {

SpringApplication.run(EurekaApplication.class, args);

}

}

4、整体项目

5、项目启动测试可能出现的问题

org.springframework.boot.builder.SpringApplicationBuilder.([Ljava/lang/Object;)V

这个原因就是你的springboot版本和eureka不匹配,按照我的就可以了

6、启动项目测试

出现下面搭建成功

精彩内容

评论可见,请评论后查看内容,谢谢!!!评论后请刷新页面。