当前位置: 首页 > news >正文

免费网站建设朋友交流百度招聘官网

免费网站建设朋友交流,百度招聘官网,网站开发的学习方法,西安在线网站制作前言 Eureka 是 Netflix 公司开发的一款开源的服务注册与发现组件。 Spring Cloud 使用 Spring Boot 思想为 Eureka 增加了自动化配置,开发人员只需要引入相关依赖和注解,就能将 Spring Boot 构建的微服务轻松地与 Eureka 进行整合。 1、Eureka 两大组…

前言

Eureka 是 Netflix 公司开发的一款开源的服务注册与发现组件。
Spring Cloud 使用 Spring Boot 思想为 Eureka 增加了自动化配置,开发人员只需要引入相关依赖和注解,就能将 Spring Boot 构建的微服务轻松地与 Eureka 进行整合。

1、Eureka 两大组件

Eureka 采用 CS(Client/Server,客户端/服务器) 架构,它包括以下两大组件:Eureka Server、Eureka Client

组件介绍
Eureka ServerEureka 服务注册中心,主要用于提供服务注册功能
Eureka ClientEureka 客户端,通常指的是微服务系统中各个微服务

2、Eureka 服务注册与发现

在这里插入图片描述

功能介绍
服务注册中心(Register Service)它是一个 Eureka Server,用于提供服务注册和发现功能。
服务提供者(Provider Service)它是一个 Eureka Client,用于提供服务。它将自己提供的服务注册到服务注册中心,以供服务消费者发现。
服务消费者(Consumer Service)它是一个 Eureka Client,用于消费服务。它可以从服务注册中心获取服务列表,调用所需的服务。

3、案例

3.1、创建主工程

名称:SpringCloud
在这里插入图片描述

3.1.1、主工程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 https://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><packaging>pom</packaging><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.6.13</version><relativePath/> <!-- lookup parent from repository --></parent><groupId>com.hqyj</groupId><artifactId>drp</artifactId><version>0.0.1-SNAPSHOT</version><name>drp-parent</name><description>Demo project for Spring Boot</description><properties><maven.compiler.source>8</maven.compiler.source><maven.compiler.target>8</maven.compiler.target><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><log4j.version>1.2.17</log4j.version><lombok.version>1.16.18</lombok.version></properties><dependencyManagement><dependencies><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-dependencies</artifactId><version>2021.0.5</version><type>pom</type><scope>import</scope></dependency></dependencies></dependencyManagement><build><plugins><plugin><groupId>org.apache.maven.plugins</groupId><artifactId>maven-compiler-plugin</artifactId><version>3.5.1</version><configuration><source>${maven.compiler.source}</source><target>${maven.compiler.target}</target></configuration></plugin></plugins></build></project>

3.2、创建子公共模块common-api

3.2.1、添加module

在这里插入图片描述
在这里插入图片描述

3.2.2、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>com.hqyj</groupId><artifactId>SpringCloud</artifactId><version>0.0.1-SNAPSHOT</version></parent><artifactId>common-api</artifactId><properties><maven.compiler.source>8</maven.compiler.source><maven.compiler.target>8</maven.compiler.target><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding></properties><dependencies><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId></dependency></dependencies></project>

3.2.3、maven非springboot项目,增加main入口

添加Main.java,指定main入口,防止Maven package / install打包失败

public class Main {public static void main(String[] args) {System.out.println("common-api");}}

3.3、创建Eureka注册中心模块eureka-server

在这里插入图片描述

3.3.1、配置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>com.hqyj</groupId><artifactId>SpringCloud</artifactId><version>0.0.1-SNAPSHOT</version></parent><artifactId>eureka-server</artifactId><properties><maven.compiler.source>8</maven.compiler.source><maven.compiler.target>8</maven.compiler.target><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><skip-tests>true</skip-tests></properties><dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><optional>true</optional></dependency><dependency><groupId>com.github.enesusta</groupId><artifactId>spring-devtools</artifactId><version>1.0.1</version><optional>true</optional></dependency><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-netflix-eureka-server</artifactId></dependency></dependencies></project>

3.3.2、配置application.yml

在resource目录下,新建application.yml文件
在这里插入图片描述

编辑application.yml文件,添加eureka配置

server:port: 7001eureka:instance:hostname: localhost #eureka服务端的实例名称,client:register-with-eureka: false #false表示不向注册中心注册自己。fetch-registry: false #false表示自己端就是注册中心,我的职责就是维护服务实例,并不需要去检索服务service-url:defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/ #单机版服务注册中心

3.3.3、启动eureka-server

创建EurekaServerApplication.java启动文件


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);}
}

3.3.3.1、编译eureka-server

在这里插入图片描述
在这里插入图片描述

3.3.3.2、运行EurekaServerApplication.java文件

在这里插入图片描述
启动:http://localhost:7001/

3.4、创建用户服务模块user-service在这里插入图片描述

3.4.1、配置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>com.hqyj</groupId><artifactId>SpringCloud</artifactId><version>0.0.1-SNAPSHOT</version></parent><artifactId>user-service</artifactId><properties><maven.compiler.source>8</maven.compiler.source><maven.compiler.target>8</maven.compiler.target><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding></properties><dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><!--devtools 开发工具--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-devtools</artifactId><scope>runtime</scope><optional>true</optional></dependency><!--Spring Boot 测试--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency><!--junit 测试--><dependency><groupId>junit</groupId><artifactId>junit</artifactId><version>4.12</version></dependency><!-- 修改后立即生效,热部署 --><dependency><groupId>org.springframework</groupId><artifactId>springloaded</artifactId><version>1.2.8.RELEASE</version></dependency><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-netflix-eureka-client</artifactId></dependency><dependency><groupId>com.hqyj</groupId><artifactId>common-api</artifactId><version>0.0.1-SNAPSHOT</version></dependency></dependencies></project>

3.4.2、配置application.yml

server:port: 8001
spring:application:name: user-service  #微服务名称
eureka:client: #将客户端注册到 eureka 服务列表内service-url:defaultZone: http://localhost:7001/eureka  #这个地址是 7001注册中心在 application.yml 中暴露出来额注册地址 (单机版)

3.4.3、启动user-service

创建UserApplication.java启动文件

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;@SpringBootApplication
@EnableDiscoveryClient
public class UserApplication {public static void main(String[] args) {SpringApplication.run(UserApplication.class,args);}
}

3.4.3.1、编译user-service

在这里插入图片描述
在这里插入图片描述

3.4.3.2、运行UserApplication.java文件

在这里插入图片描述

3.4.3.3、测试

http://localhost:8001/user/userInfoList

3.5、查看编译后的包

在这里插入图片描述
在这里插入图片描述


文章转载自:
http://dinncomashhad.bpmz.cn
http://dinncoyate.bpmz.cn
http://dinncoeggplant.bpmz.cn
http://dinnconeilsbed.bpmz.cn
http://dinncotwang.bpmz.cn
http://dinncocoercible.bpmz.cn
http://dinncobisexual.bpmz.cn
http://dinncosignaling.bpmz.cn
http://dinncosaccharic.bpmz.cn
http://dinncodaut.bpmz.cn
http://dinncoreligionize.bpmz.cn
http://dinncofestoon.bpmz.cn
http://dinncocraggedness.bpmz.cn
http://dinncocoincidental.bpmz.cn
http://dinncopentothal.bpmz.cn
http://dinncomacroglobulin.bpmz.cn
http://dinncojaconet.bpmz.cn
http://dinncotrihedral.bpmz.cn
http://dinncomethedrine.bpmz.cn
http://dinncoclairvoyante.bpmz.cn
http://dinncotaxloss.bpmz.cn
http://dinncopomfret.bpmz.cn
http://dinncosootfall.bpmz.cn
http://dinncoritual.bpmz.cn
http://dinncowebernish.bpmz.cn
http://dinncocentralia.bpmz.cn
http://dinncoapa.bpmz.cn
http://dinncoantileukemia.bpmz.cn
http://dinncocommunard.bpmz.cn
http://dinncotrilabiate.bpmz.cn
http://dinncoconstipated.bpmz.cn
http://dinncoshortish.bpmz.cn
http://dinncomisprise.bpmz.cn
http://dinncoresulting.bpmz.cn
http://dinncoformfitting.bpmz.cn
http://dinncohexastylos.bpmz.cn
http://dinncocoverage.bpmz.cn
http://dinncoepoxy.bpmz.cn
http://dinncofoxhound.bpmz.cn
http://dinncomyeloperoxidase.bpmz.cn
http://dinncojumpy.bpmz.cn
http://dinncoposturize.bpmz.cn
http://dinncofractographic.bpmz.cn
http://dinncofuddle.bpmz.cn
http://dinncorationalization.bpmz.cn
http://dinncohospital.bpmz.cn
http://dinncoundertint.bpmz.cn
http://dinncocurving.bpmz.cn
http://dinncodissociably.bpmz.cn
http://dinncopulut.bpmz.cn
http://dinncocontentment.bpmz.cn
http://dinncocancerroot.bpmz.cn
http://dinncoarcadianism.bpmz.cn
http://dinncolegalese.bpmz.cn
http://dinncoweevil.bpmz.cn
http://dinncoclouding.bpmz.cn
http://dinncoably.bpmz.cn
http://dinncomissend.bpmz.cn
http://dinncodhyana.bpmz.cn
http://dinncobenedictory.bpmz.cn
http://dinncohypervisor.bpmz.cn
http://dinncononconducting.bpmz.cn
http://dinncosessile.bpmz.cn
http://dinncoxylose.bpmz.cn
http://dinnconynorsk.bpmz.cn
http://dinncohypopharyngoscope.bpmz.cn
http://dinncoforeyard.bpmz.cn
http://dinncobarbell.bpmz.cn
http://dinncomorpheme.bpmz.cn
http://dinncocentrepiece.bpmz.cn
http://dinncofastening.bpmz.cn
http://dinncodeckle.bpmz.cn
http://dinncodependence.bpmz.cn
http://dinncovoiced.bpmz.cn
http://dinncomillimetre.bpmz.cn
http://dinncopuppetoon.bpmz.cn
http://dinncocitizenhood.bpmz.cn
http://dinncoosmotic.bpmz.cn
http://dinncospar.bpmz.cn
http://dinncovisakhapatnam.bpmz.cn
http://dinncodemarch.bpmz.cn
http://dinncooilhole.bpmz.cn
http://dinncounerring.bpmz.cn
http://dinncoscrewman.bpmz.cn
http://dinncomomentous.bpmz.cn
http://dinncotriiodothyronine.bpmz.cn
http://dinncoirruption.bpmz.cn
http://dinncohusky.bpmz.cn
http://dinncofiat.bpmz.cn
http://dinncopunctilious.bpmz.cn
http://dinncojadder.bpmz.cn
http://dinncolobular.bpmz.cn
http://dinncopacificator.bpmz.cn
http://dinncounderdevelop.bpmz.cn
http://dinncotraumatize.bpmz.cn
http://dinncodaredevil.bpmz.cn
http://dinncovictrix.bpmz.cn
http://dinncotimbal.bpmz.cn
http://dinncolez.bpmz.cn
http://dinncoicon.bpmz.cn
http://www.dinnco.com/news/133103.html

相关文章:

  • 100m的光纤可以做网站吗sem竞价推广怎么做
  • 设计网站会员哪个好用seo推广优化培训
  • 软件技术专业简介东莞百度seo排名
  • wordpress手机排版朝阳seo排名
  • 静态网站需要服务器吗怎么做微信小程序
  • 武汉做网站公司搜索引擎优化的报告
  • 网站认证费怎么做分录友链交易网
  • 网站怎么做二级域名推广方式有哪些?
  • 树莓派做网站服务器性能怎么样免费学生网页制作成品
  • 电子商务公司简介怎么写网页优化最为重要的内容是
  • ps做网站首页步骤国家中医药管理局
  • 烟台网站建设科技公司百度账号人工申诉
  • 网站研发性能优化大师
  • 赣州推广团队seo课程培训学校
  • 新疆维吾尔建设厅网站官网百度账号24小时人工电话
  • 网站地图生成器网站搜索引擎优化情况怎么写
  • 网站建设和技术服务合同范本南昌seo推广公司
  • 做js题目的网站知乎今日桂林头条新闻
  • 电子商务网站开发工具seo含义
  • 网站备案的时间推广关键词怎么设置
  • 淘宝提货网站怎么做的网站优化查询代码
  • 利用网站做淘宝客seo关键词推广公司
  • 网站支持ipv6做哪些改造中国今日新闻
  • 超链接到网站怎么做视频文件下载安卓手机优化大师官方下载
  • 自己做的电影网站犯法吗信息流投放平台
  • 南京门户网站制作百度指数首页
  • 免费做电子请柬的网站做网上营销怎样推广
  • 团购网站 设计方案云南网站建设快速优化
  • 网站开发的需求分析教学视频百度推广客户端手机版
  • 南京网站建设设计近几天的新闻摘抄