Spring Assistant创建Eureka服务的项目
2020-05-21 本文已影响0人
townof1997
1,如果idea没有Spring Assistant插件,先下载插件file--->settings--->Plugins--->Spring Assistant安装重启idea

3,填写自己项目的信息,我选择使用的是maven

4,

5,然后在pom.xml文件里面加入依赖:
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
4,修改启动类,添加Eureka Server的annotation,@EnableEurekaServer

5,在application.properties里面加入以下内容
#端口号
server.port=8081
eureka.instance.hostname=localhost
#向注册中心注册服务
eureka.client.registerWithEureka=false
# 检索服务
eureka.client.fetchRegistry=false
eureka.client.serviceUrl.defaultZone=http://${eureka.instance.hostname}:${server.port}/eureka/
#在Eureka服务器获取不到集群里对等服务器上的实例时,需要等待的时间
server.waitTimeInMsWhenSyncEmpty=0
#自我保护模式
server.enableSelfPreservation=false
5,启动Eureka Server
