初始化Spring Cloud建立Eureka服务注册中心

1、新建项目

https://gitee.com/frankawp/vishnu  新建一个git项目

打开git bash

git clone https://gitee.com/frankawp/vishnu

git remote add vishnu https://gitee.com/frankawp/vishnu

touch test

git add .

git commit -m initial

git push origin master

初始化git完毕

刷新https://gitee.com/frankawp/vishnu  多了一个test文件

2、新建一个spring cloud的服务注册中心

登录https://start.spring.io/

先建一个注册中心

Group: cn.battlecruiser.vishnu

Artifact: vishnu-eureka

Search for dependencies :Eureka Server

Generate project

下载下来后,解开,将vishnu-eureka 放在vishnu目录下

为加快maven下载速度,加aliyun的maven仓库,maven settings.xml里

<mirror>

<id>nexus-aliyun</id>

<mirrorOf>central</mirrorOf>

<name>Nexus aliyun</name>

<url>https://maven.aliyun.com/nexus/content/groups/public</url>

</mirror>

spring.io上初始化的工程用的是application.properties .  删掉好了,用bootstrap.yml内容如下

server:

port: 1025

spring:

application:

name: vishnu-eureka-server

eureka:

client:

fetch-registry: false

register-with-eureka: false

serviceUrl:

defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/

instance:

hostname: localhost

server:  #配置属性,但由于 Eureka 自我保护模式以及心跳周期长的原因,经常会遇到 Eureka Server 不剔除已关停的节点的问题

enable-self-preservation: false

eviction-interval-timer-in-ms: 5000

测试一下:

cd vishnu-eureka

mvn clean package

mvn spring-boot:run

启动成功

http://localhost:1025/actuator 可以访问

但是登录不了主页 http://localhost:1025

main方法上没有@EnableEurekaServer注解   重启  可以了,不知道它的默认工程为什么没加这个。

3、加安全

pom.xml 加

<dependency>

<groupId>org.springframework.cloud</groupId>

<artifactId>spring-cloud-starter-security</artifactId>

</dependency>

启动后控制台会打印一个随机密码

Using generated security password: eaeed05e-a0ea-42aa-81d5-e27b485ba6ef

用户名是 : user

如果要自定义

bootstrap.yml中加

security:

basic:

enabled: true # 启用身份认证

user:

name: frank # 定义用户名

password: frank123 # 定义密码

4、git push

git add .

git commit -m eureka-init

git push

原文地址:https://www.cnblogs.com/frankawp/p/10116273.html

时间: 2024-08-28 04:21:47

初始化Spring Cloud建立Eureka服务注册中心的相关文章

spring cloud实战 1-高可用注册中心

创建父maven项目 提交代码至GitHub 创建eureka-server-1 项目搭建两种方式: 父pom中继承spring-boot-starter-parent,子pom中直接结成父pom.该方式比较方便,但子项目都是spring boot项目了. 父项目不需要继承spring-boot-starter-parent,子pom中通过使用scope = import依赖关系. 123456789101112 <dependencyManagement> <dependencies&

Spring Cloud Consul 实现服务注册和发现

Spring Cloud 是一个基于 Spring Boot 实现的云应用开发工具,它为基于 JVM 的云应用开发中涉及的配置管理.服务发现.断路器.智能路由.微代理.控制总线.全局锁.决策竞选.分布式会话和集群状态管理等操作提供了一种简单的开发方式.通过 Spring Boot 风格进行再封装屏蔽掉了复杂的配置和实现原理,最终给开发者留出了一套简单易懂.易部署和易维护的分布式系统开发工具包. Spring Cloud 包含了多个子项目(针对分布式系统中涉及的多个不同开源产品),比如:Sprin

Spring Cloud Eureka 服务注册中心(二)

序言 Eureka 是 Netflix 开发的,一个基于 REST 服务的,服务注册与发现的组件 它主要包括两个组件:Eureka Server 和 Eureka Client Eureka Client:一个Java客户端,用于简化与 Eureka Server 的交互(通常就是微服务中的客户端和服务端) Eureka Server:提供服务注册和发现的能力(通常就是微服务中的注册中心) 各个微服务启动时,会通过 Eureka Client 向 Eureka Server 注册自己,Eurek

Spring Cloud 一:服务注册与发现(Eureka)【Dalston版】

Spring Cloud简介 Spring Cloud是一个基于Spring Boot实现的云应用开发工具,它为基于JVM的云应用开发中涉及的配置管理.服务发现.断路器.智能路由.微代理.控制总线.全局锁.决策竞选.分布式会话和集群状态管理等操作提供了一种简单的开发方式. 微服务架构 那么什么是"微服务架构"呢?简单的说,微服务架构就是将一个完整的应用从数据存储开始垂直拆分成多个不同的服务,每个服务都能独立部署.独立维护.独立扩展,服务与服务间通过诸如RESTful API的方式互相调

Spring Cloud Learning(一): 服务注册

官网https://projects.spring.io/spring-cloud/,spring cloud官网各组件版本为: Component Edgware.SR4 Finchley.SR1 Finchley.BUILD-SNAPSHOT spring-cloud-aws 1.2.3.RELEASE 2.0.0.RELEASE 2.0.1.BUILD-SNAPSHOT spring-cloud-bus 1.3.3.RELEASE 2.0.0.RELEASE 2.0.1.BUILD-SNA

【转】Eureka服务注册中心搭建

转自:https://blog.csdn.net/pengjunlee/article/details/86538997 Spring Cloud是一系列框架的集合,它利用Spring Boot的开发便利性巧妙地简化了分布式系统基础设施的开发,构建了服务治理(服务注册与发现).配置中心.消息总线.负载均衡.断路器.数据监控.分布式会话和集群状态管理等功能,为我们提供一整套企业级分布式云应用的完美解决方案. Spring Cloud的服务治理等核心功能主要是通过Spring Cloud Netfl

没使用Spring Cloud的版本管理导致Eureka服务无法注册到Eureka服务注册中心

创建了一个Eureka Server的服务注册集群(两个Eureka服务),都能相互注册,写了一个Eureka客户端服务无法注册到服务发现注册中心 注册中心1: 注册中心2: 服务正常: pom依赖文件: <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://

《Spring Cloud Netflix》 -- 服务注册和服务发现-Eureka的常用配置

一.版本的说明 Angel版本对应Spring Boot 1.2.x,可以使用Spring Boot 1.3.x: Brixton版本对应Spring Boot 1.3.x,可以使用Spring Boot 1.4.x: Camden版本对应Spring Boot 1.4.x,可以使用Spring Boot 1.5.x: Dalston版本对应Spring Boot 1.5.x 二.应用进行热部署 添加依赖: 重启即可! 注意:如果是增加了jar包,还是需要关闭重启. 三.Eureka常用配置 a

《Spring Cloud Netflix》-- 服务注册和服务发现-Eureka的服务认证和集群

一. Eureka的服务认证 1. 服务端添加依赖 <dependency>      <groupId>org.springframework.boot</groupId>      <artifactId>spring-boot-starter-security</artifactId> </dependency> 2. 服务端添加配置 # 服务认证 security.basic.enabled=true security.use