1、Eureka简介 

  Eureka是Spring Cloud Netflix微服务套件中的一部分,是一套成熟的服务注册和发现组件,可以与Springboot构建的微服务很容易的整合起来。

  Eureka包含服务器端和客户端组件

    服务器用于服务注册服务器

    客户端是一个Java客户端,用来简化与服务器的交互,作为轮询负载均衡器,并提供服务的故障切换支持

2、Springcloud父工程需要的依赖文件

 <parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.7.RELEASE</version>
<relativePath/>
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<junit.version>4.12</junit.version>
<spring-cloud.version>Finchley.SR2</spring-cloud.version>
</properties>
<!--依赖声明-->
<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>
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>1.3.2</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>druid</artifactId>
<version>1.1.12</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.13</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency> <dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.10</version>
<scope>provided</scope>
</dependency>
</dependencies>
</dependencyManagement>

3、子工程的一个properties.yml文件

 server:
port: 8001
mybatis:
config-location: classpath:mybatis/mybatis.cfg.xml # mybatis配置文件所在路径
type-aliases-package: com.offcn.springcloud.entity # 所有Entity别名类所在包
mapper-locations: classpath:mybatis/mapper/**/*.xml # mapper映射文件
spring:
application:
name: microservice-product #这个很重要,这在以后的服务与服务之间相互调用一般都是根据这个name
datasource:
type: com.alibaba.druid.pool.DruidDataSource # 当前数据源操作类型
driver-class-name: com.mysql.cj.jdbc.Driver # mysql驱动包
url: jdbc:mysql://127.0.0.1:3306/day3?serverTimezone=GMT%2B8 # 数据库名称
username: root
password: root
dbcp2:
min-idle: 5 # 数据库连接池的最小维持连接数
initial-size: 5 # 初始化连接数
max-total: 5 # 最大连接数
max-wait-millis: 150 # 等待连接获取的最大超时时间
eureka:
instance:
hostname: EurekaServer01
client:
register-with-eureka: true #此EurekaServer不在注册到其他的注册中心
fetch-registry: true #不在从其他中心中心拉取服务器信息
service-url:
defaultZone: http://localhost:6001/eureka/,http://eureka6001.com:6001/eureka #注册中心访问地址

4、另一个文件

 #内置的tomcat服务启动监听端口号
server:
port: 8888
#应用名称
spring:
application:
name: EurekaServer01
#EurekaServer配置
eureka:
client:
register-with-eureka: false #此EurekaServer不在注册到其他的注册中心
fetch-registry: false #不在从其他中心中心拉取服务器信息
service-url:
defaultZone: http://localhost:${server.port}/eureka #注册中心访问地址

5、完整的代码没上传,太多这里附上GitHub地址https://github.com/Leo-12/springboot.git

简单了解Eureka的更多相关文章

  1. (转)微服务_创建一个简单的Eureka注册中心

    原文地址:https://www.cnblogs.com/lplshermie/p/9105329.html 微服务和分布式已经成了一种极其普遍的技术,为了跟上时代的步伐,最近开始着手学习Spring ...

  2. 创建一个简单的Eureka注册中心

    微服务和分布式已经成了一种极其普遍的技术,为了跟上时代的步伐,最近开始着手学习SpringCloud,就从Eureka开始.他们俩就不做介绍了,网上的说明一堆,随便打开一个搜索引擎输入关键字都足够了解 ...

  3. 搭建一个简单的Eureka程序

    Eureka集群主要有三个部分Eureka服务器,服务提供者,服务调用者 简单的来说就是服务提供者将服务注册到Eureka服务器,服务调用者对其服务进行查找调用. Eureka服务程序的搭建可参考官方 ...

  4. spring cloud 创建一个简单Eureka Server

    在Spring Cloud实现一个Eureka Server是一件非常简单的事情.下面我们来写一个Eureka Server DEMO. 编码 父项目pom.xml <?xml version= ...

  5. 搭建eureka服务

    1.pom.xml <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www ...

  6. Spring cloud Greenwich Eureka

    1.父工程POM文件中: <dependencyManagement> <dependencies> <!--spring cloud--> <depende ...

  7. 第一个Eureka程序,Eureka Client的自启动原理和简要过程

    https://blog.csdn.net/u011531425/article/details/81675289 在之前的Spring Cloud Config的基础上,搭建简单的Eureka Se ...

  8. 【Dalston】【第一章】 服务治理(Eureka)

    Spring Cloud是一系列框架的集合,其基于Spring Boot的开发便利性巧妙地简化了分布式系统基础设施的开发,构建了服务治理(发现注册).配置中心.消息总线.负载均衡.断路器.数据监控.分 ...

  9. Spring Cloud 入门 之 Eureka 篇(一)

    原文地址:Spring Cloud 入门 之 Eureka 篇(一) 博客地址:http://www.extlight.com 一.前言 Spring Cloud 是一系列框架的有序集合.它利用 Sp ...

随机推荐

  1. detectron2安装出现Kernel not compiled with GPU support 报错信息

    在安装使用detectron2的时候碰到Kernel not compiled with GPU support 问题,前后拖了好久都没解决,现总结一下以备以后查阅. 不想看心路历程的可以直接跳到最后 ...

  2. ajax 简单例子

    Html 代码: <html> <body> <div id="myDiv"><h3>Let AJAX change this te ...

  3. django 解析上传xls文件

    1.解析上传数据 class DataUploadAPIView(APIView): # authentication_classes = (JSONWebTokenAuthentication, S ...

  4. node开发遇到类似:Error: ENOENT: no such file or directory, scandir 'D:\work\taro-components- ....... _node-sass@4.12.0@node-sass\vendor

    唯一的有参考价值的文章,https://www.cnblogs.com/milo-wjh/p/9175138.html 我可以负责任的说,以下的方法, npm rebuild node-sass 80 ...

  5. PDB files out of the debugger

    我想我不需要强调在调试时拥有有效的PDB文件有多重要.通常,PDB文件是由调试器静默加载的,并且您很高兴在modules窗口中看到解析的所有符号.不幸的是,您还可能遇到调试器找不到匹配符号的情况.其原 ...

  6. 洛谷 P2253 好一个一中腰鼓! 题解

    P2253 好一个一中腰鼓! 题目背景 话说我大一中的运动会就要来了,据本班同学剧透(其实早就知道了),我萌萌的初二年将要表演腰鼓[喷],这个无厘头的题目便由此而来. Ivan乱入:"忽一人 ...

  7. 解析node-cors模块

    (function () { 'use strict'; var assign = require('object-assign'); var vary = require('vary'); var ...

  8. java报错:The reference to entity "characterEncoding" must end with the ';' delimiter.

    java关于报错:The reference to entity "characterEncoding" must end with the ';' delimiter. Java ...

  9. 【IntelliJ IDEA学习之八】版本控制之SVN

    版本:IntelliJIDEA2018.1.4 一.SVN1.安装SVN客户端,command line client tools默认是不安装的,这里要勾选上(不用重新卸载安装,只找到安装程序,选择  ...

  10. .NET 微服务 1. Docker 容器简介和选择

    容器特点 1. 容器可以将应用程序的依赖性和配置(抽象为 Mainfest 文件并部署)打包成一个容器镜像,可以让多次部署操作中的环境保持一致 2. 可以让IT人员很少或者不做修改就可以跨环境部署软件 ...