一、准备开发环境和开发工具
jdk1.8,idea开发工具,maven管理工具
二、新建一个maven项目(方便后续操作管理)
完成后删除src目录的所有东西
新建注册中心项目
pom
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
application.properties配置
server.port=8000
eureka.instance.hostname=localhost
#是否开启自己的注册
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false
eureka.client.service-url.defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
EurekaApplication 启动文件主要是@EnableEurekaServer注释
package com.eureka;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
@SpringBootApplication
@EnableEurekaServer
public class EurekaApplication {
public static void main(String[] args) {
SpringApplication.run(EurekaApplication.class, args);
}
}