转载引用参考了
https://blog.csdn.net/hcmony/article/details/77855158
https://www.cnblogs.com/huangjuncong/p/9020474.html
整体机构图
1、新建项目,选择Create New Project
2、 下一步
3、下一步
4、这一步与创建springboot有区别,注意下面的选择
选择Spring Cloud Discovery 和 Eureka Server
5、 修改启动类如下
注意!!!添加了
package com.chenclass.xaeureaka;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
@EnableEurekaServer
@SpringBootApplication
public class XaeureakaApplication {
public static void main(String[] args) {
SpringApplication.run(XaeureakaApplication.class, args);
}
}
6、修改application.properties的配置文件
server.port=8761
eureka.instance.hostname=127.0.0.1
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false
eureka.client.service-url.defaultZone= http://${eureka.instance.hostname}:${server.port}/eureka/