一:建立一个springboot模块
二:pom.xml 加入
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
三:启动类加注解@EnableEurekaServer
@SpringBootApplication
@EnableEurekaServer
public class EurekaMain7001
{
public static void main( String[] args )
{
SpringApplication.run(EurekaMain7001.class,args);
}
}
四 配置文件yml
server:
port: 7001 #服务端口
eureka:
instance:
hostname: localhost
client:
register-with-eureka: false
fetch-registry: false
service-url:
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
五:启动项目,结果如下则成功