初始化SpringBoot,配置POM(版本2.0.0 M3)
<properties>
<java.version>1.8</java.version>
<!-- 指定SpringCloud版本 -->
<spring-cloud.version>Finchley.M2</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- Eureka 集成 -->
<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>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
Eureka配置文件
server.port=8761
#设置当前实例主机名称
eureka.instance.hostname=localhost
#是否启动注册服务
eureka.client.registerWithEureka=false
#是否检索服务
eureka.client.fetchRegistry=false
#指定服务注册中心地址
eureka.client.serviceUrl.defaultZone=http://${eureka.instance.hostname}:${server.port}/eureka/
启动服务并访问
http://localhost:8761/ ,访问地址并打开页面效果: