Eureka注册中心服务
1.新建服务模块
在之前创建好的SpringCloud项目中,新建普通Maven模块,取名为springcloud-eureka-7001
2.导入依赖
在该模块的pom.xml文件中导入如下依赖
注意:该Eureka依赖已经停止维护
<!--导入Eureka包和热部署-->
<dependencies>
<!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-netflix-eureka-server -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
<version>2.2.5.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
</dependencies>
3.配置
在resource目录下新建application.yaml,进行服务器端口和Eureka配置
server:
port: 7001
#Eureka配置
eureka:
instance:
hostname: localhost #Eureka服务端的实例名称
client:
register-with-eureka: false #表示是否向Eureka注册中心注册自己
fetch-registry: false #fetch-registry如果为false,则表示自己为注册中心
service-url: #监控页面
defaultZone: http://${
eureka.instance.hostname}:$