微服务实战系列(一)-注册中心Springcloud Eureka服务端-copy
1. 场景描述
springcloud提供了一整套可行的构建分布式系统的方案,使的企业/开发人员能够快速沟通分布式系统,今天快速构建下springcloud的注册中心Eureka。
2. 解决方案
2.1 springcloud介绍
COORDINATE ANYTHING: DISTRIBUTED SYSTEMS SIMPLIFIED
Building distributed systems doesn't need to be complex and error-prone. Spring Cloud offers a simple and accessible programming model to the most common distributed system patterns, helping developers build resilient, reliable, and coordinated applications. Spring Cloud is built on top of Spring Boot, making it easy for developers to get started and become productive quickly.

2.2 项目构建
使用的idea终极版,springcloud项目本身就是springboot项目(springboot与springcloud的关系)。
首先在idea中创建项目:file-->new-->project

两个默认next后选择组件

默认next->finish
2.3 配置文件pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.spc</groupId>
<artifactId>eurekaserver</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>eurekaserver</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>Greenwich.SR1</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
说明:
(1)springcloud本身是springboot项目,新建springboot项目。
(2)需要两个starter,eureka-server和eureka-client
如果你觉得文章对你有些帮助,欢迎微信搜索「软件老王」第一时间阅读或交流!
2.4 application启动类
package com.spc.eurekaserver;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
@SpringBootApplication
@EnableEurekaServer
public class EurekaserverApplication {
public static void main(String[] args) {
SpringApplication.run(EurekaserverApplication.class, args);
}
}
说明:
比springboot项目多了一个标签:@EnableEurekaServer,该标签用于标注是注册中心。
2.5 application.yml文件
spring:
application:
name: registry
server:
port: 8761
eureka:
client:
register-with-eureka: false
service-url:
defaultZone: http://localhost:8761/eureka/
说明:
(1)name为项目名称;
(2)port: 8761为启动端口。
(3)eureka下面的配置暂时不用,后续用于在高可用配置的时候,作为客户端注册到另一台注册中心,实现高可用。
2.6 启动应用

更多知识请关注公众号:「软件老王」,IT技术与相关干货分享,回复关键字获取对应干货,java,送必看的10本“武功秘籍”;图片,送100多万张可商用高清图片;面试,送刚毕业就能月薪“20k”的java面试题,软考,送官方pdf书籍与通关论文,后续会不断更新,比如“工具”,“视频”等,已经在整理中。
微服务实战系列(一)-注册中心Springcloud Eureka服务端-copy的更多相关文章
- 微服务实战系列--Nginx官网发布(转)
这是Nginx官网写的一个系列,共七篇文章,如下 Introduction to Microservices (this article) Building Microservices: Using ...
- go-zero微服务实战系列(三、API定义和表结构设计)
前两篇文章分别介绍了本系列文章的背景以及根据业务职能对商城系统做了服务的拆分,其中每个服务又可分为如下三类: api服务 - BFF层,对外提供HTTP接口 rpc服务 - 内部依赖的微服务,实现单一 ...
- go-zero微服务实战系列(十一、大结局)
本篇是整个系列的最后一篇了,本来打算在系列的最后一两篇写一下关于k8s部署相关的内容,在构思的过程中觉得自己对k8s知识的掌握还很不足,在自己没有理解掌握的前提下我觉得也很难写出自己满意的文章,大家看 ...
- Chris Richardson微服务实战系列
微服务实战(一):微服务架构的优势与不足 微服务实战(二):使用API Gateway 微服务实战(三):深入微服务架构的进程间通信 微服务实战(四):服务发现的可行方案以及实践案例 微服务实践(五) ...
- 微服务实战(六):选择微服务部署策略 - DockOne.io
原文:微服务实战(六):选择微服务部署策略 - DockOne.io [编者的话]这篇博客是用微服务建应用的第六篇,第一篇介绍了微服务架构模板,并且讨论了使用微服务的优缺点.随后的文章讨论了微服务不同 ...
- 微服务实战(三):深入微服务架构的进程间通信 - DockOne.io
原文:微服务实战(三):深入微服务架构的进程间通信 - DockOne.io [编者的话]这是采用微服务架构创建自己应用系列第三篇文章.第一篇介绍了微服务架构模式,和单体式模式进行了比较,并且讨论了使 ...
- ASP.NET Core微服务实战系列
希望给你3-5分钟的碎片化学习,可能是坐地铁.等公交,积少成多,水滴石穿,码字辛苦,如果你吃了蛋觉得味道不错,希望点个赞,谢谢关注. 前言 这里记录的是个人奋斗和成长的地方,该篇只是一个系列目录和构想 ...
- 微服务实战系列(二)-注册中心Springcloud Eureka客户端
1. 场景描述 前几天介绍了下springcloud的Eureka注册中心(springcloud-注册中心快速构建),今天结合springboot-web介绍下eureka客户端服务注册. 2. 解 ...
- 微服务实战系列(四)-注册中心springcloud alibaba nacos
1.场景描述 因要用到微服务,关于注册中心这块,与同事在技术原型上做了讨论,初步定的方案是使用:阿里巴巴的nacos+springcloud gateway,下面表格是同事整理的注册中心对比,以前用的 ...
- 微服务实战系列(五)-注册中心Eureka与nacos区别
1. 场景描述 nacos最近用的比较多,介绍下nacos及部署吧,刚看了下以前写过类似的,不过没写如何部署及与eureka区别,只展示了效果,补补吧. 2.解决方案 2.1 nacos与eureka ...
随机推荐
- Linux系统压力测试工具(命令行工具)
Linux的命令行压力测试工具在做基准测试时很有用,通过基准测试对了解一个系统所能达到的最大性能指标,这些指标可以作为后续性能比较.优化评估的参考依据. 模拟CPU压力: 可以使用stress命令使C ...
- 新一代AI换脸更自然,DeepLiveCam下载介绍(可直播)
DeepLiveCam是一款基于人工智能的图片替换工具,专注于提供实时人脸交换和一键视频深度伪造(deepfake)技术,能通过使用单张图片,在视频或直播中实现高精度的人脸替换 DeepLiveCam ...
- PC大屏自适应 - 简洁版
PC大屏自适应通常做法 一般pc端页面布局会取中间一定的宽度,高度自适应.而可视化大屏需要在不同分辨率的显示屏上铺满整个屏幕,这就需要根据屏幕不同分辨率设置不同的宽高也就是自适应布局.在此向小伙伴们推 ...
- pyenv: no such command `virtualenv'
当执行 pyenv virtualenv 3.6.10 env_3.6.10 命令创建新的python环境时提示 pyenv: no such command `virtualenv' larryma ...
- 关于Air780E:与服务器的加密通信操作方法
今天我们来学习合宙低功耗4G模组Air780E快速入门之跟服务器之间的加密通信,伙伴们,一起学起来! 一.编写脚本 1.1 准备资料 Air780E开发板购买 Air780E开发板设计资料 Lua ...
- npm : 无法加载文件 D:\Program Files\nodejs\npm.ps1,因为在此系统上禁止运行脚本
升级node和npm之后,npm run dev 启动一个Vue项目,报错如下: npm : 无法加载文件 D:\Program Files\nodejs\npm.ps1,因为在此系统上禁止运行脚本. ...
- Memcached笔记——(一)安装&常规错误&监控
08年的时候接触过Memcached,当时还对它的客户端产品嗤之以鼻,毕竟手工代码没有各种ORM原生XML配置方便.尽管如此,Memcached现在已经成了服务器架构里不可或缺的一部分! 相关链接: ...
- Tornado框架之应用安全(四)
知识点 Cookie操作 安全Cookie 跨站请求伪造原理 XSRF保护 模板 请求体 HTTP报文头 用户验证 authenticated装饰器 get_current_user()方法 logi ...
- 一款开源、免费、美观的 Avalonia UI 原生控件库 - Semi Avalonia
前言 最近发现DotNetGuide技术社区交流群有不少小伙伴在学习Avalonia,今天大姚给大家分享一款开源.免费.美观的 Avalonia UI 原生控件库:Semi Avalonia. Ava ...
- 使用nginx 压缩
现在的程序使用单页面应用,因此程序会在一开始就会加载页面JS.如果带宽不够,那么会影响页面下载速度. 我们可以使用NGINX 进行压缩,加快文件下载. gzip on; gzip_min_length ...