启动Eureka serve
第一步 加入依赖
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
<version>3.0.5</version>
</dependency>
第二步 写主配置
server:
port: 7001
eureka:
instance:
hostname: localhost #eureka 服务端的实例名称
client:
register-with-eureka: false #表示不向注册中心注册自己
fetch-registry: false #表示自己就是注册端,其职责就是维护服务实例,并不需要检索服务
service-url:
defaultZone: http://${
eureka.instance.hostname}:${
server.port}/eureka/ #设置与EurekaServer交互的地址查询服务和注册服务都需要依赖这个地址
第三步 在主启动类的上面加注解
package com.atguigu.springcloud;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
@EnableEurekaServer
@SpringBootApplication
public class EurekaMain7001 {
public static void main(String[] args) {
SpringApplication.run(EurekaMain7001.class,arg