京东6.18大促主会场领京享红包更优惠

 找回密码
 立即注册

QQ登录

只需一步,快速开始

SpringCloud-Eureka服务中心搭建

2021-2-26 11:01| 发布者: zhaojun917| 查看: 1283| 评论: 0

摘要: 创建一个springBoot项目一、springcloud-Eureka服务中心搭建1、导入依赖dependencyManagement dependencies !-- 导入Spring Cloud的依赖管理 -- dependency groupIdorg.springframework.cloud/groupId artifactIdspr ...

创建一个springBoot项目

一、springcloud-Eureka服务中心搭建

1、导入依赖
<dependencyManagement>
	<dependencies>
		<!-- 导入Spring Cloud的依赖管理 -->
		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId>spring-cloud-dependencies</artifactId>
			<version>Finchley.SR1</version>
			<type>pom</type>
			<scope>import</scope>
		</dependency>
	</dependencies>
</dependencyManagement>

</dependencies>
	<!--springboot 整合eureka服务端-->
	<dependency>
		<groupId>org.springframework.cloud</groupId>
		<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
	</dependency>
</dependencies>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
2、yml配置文件
server:
  port: 8000

#eureka-service
eureka:
  instance:
    hostname: 127.0.0.1   #注册中心地址
  client:
    service-Url:
      defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
    register-with-eureka: false  #是否将自己注册到Eureka服务中,因为该应用本身就是注册中心,不需要再注册自己(集群的时候为true)
    fetch-registry: false        #是否从Eureka中获取注册信息,因为自己为注册中心,不会在该应用中的检索服务信息
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
3、启动类上添加注解
//启动此为一个服务注册中心
@EnableEurekaServer
  • 1
  • 2
4、启动项目

在这里插入图片描述

二、将项目注册进服务中心

新建一个springBoot项目

1.导入依赖
<dependencyManagement>
	<dependencies>
		<!-- 导入Spring Cloud的依赖管理 -->
		<dependency>
			<groupId>org.springframework.cloud</groupId>
			<artifactId
关闭

站长推荐上一条 /6 下一条

QQ|手机版|小黑屋|梦想之都-俊月星空 ( 粤ICP备18056059号 )|网站地图

GMT+8, 2025-7-1 19:17 , Processed in 0.036607 second(s), 19 queries .

Powered by Mxzdjyxk! X3.5

© 2001-2025 Discuz! Team.