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

杭州海淀区网站建设成都网站建设哪里好

杭州海淀区网站建设,成都网站建设哪里好,青岛网站建设方案策划,假网站是怎么做的系列文章目录 第一章 Java线程池技术应用 第二章 CountDownLatch和Semaphone的应用 第三章 Spring Cloud 简介 第四章 Spring Cloud Netflix 之 Eureka 文章目录 系列文章目录[TOC](文章目录) 前言1、Eureka 两大组件2、Eureka 服务注册与发现3、案例3.1、创建主工程3.1.1、主…系列文章目录 第一章 Java线程池技术应用 第二章 CountDownLatch和Semaphone的应用 第三章 Spring Cloud 简介 第四章 Spring Cloud Netflix 之 Eureka 文章目录 系列文章目录[TOC](文章目录) 前言1、Eureka 两大组件2、Eureka 服务注册与发现3、案例3.1、创建主工程3.1.1、主工程pom.xml配置 3.2、创建子公共模块common-api3.2.1、添加module3.2.2、pom.xml配置3.2.3、maven非springboot项目增加main入口 3.3、创建Eureka注册中心模块eureka-server3.3.1、配置pom.xml3.3.2、配置application.yml3.3.3、启动eureka-server3.3.3.1、编译eureka-server3.3.3.2、运行EurekaServerApplication.java文件 3.4、创建用户服务模块user-service![在这里插入图片描述](https://img-blog.csdnimg.cn/e52d0b166629469baa1cd934714c9831.png)3.4.1、配置pom.xml3.4.2、配置application.yml3.4.3、启动user-service3.4.3.1、编译user-service3.4.3.2、运行UserApplication.java文件3.4.3.3、测试 3.5、查看编译后的包 小结 前言 今天我们讲解Spring Cloud微服务的第一代实现Spring Cloud Netflix Eureka 是 Netflix 公司开发的一款开源的服务注册与发现组件。 Spring Cloud 使用 Spring Boot 思想为 Eureka 增加了自动化配置开发人员只需要引入相关依赖和注解就能将 Spring Boot 构建的微服务轻松地与 Eureka 进行整合。 附简单的Netflix微服务架构图Zuul太麻烦直接由Gateway替代 Alibaba微服务架构图 想在Netflix、Alibaba之间切换的可以看下图替换掉相关组件核心业务代码基本没有太大变化。 1、Eureka 两大组件 Eureka 采用 CSClient/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 version1.0 encodingUTF-8? project xmlnshttp://maven.apache.org/POM/4.0.0 xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsdmodelVersion4.0.0/modelVersionpackagingpom/packagingparentgroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-parent/artifactIdversion2.6.13/versionrelativePath/ !-- lookup parent from repository --/parentgroupIdcom.hqyj/groupIdartifactIddrp/artifactIdversion0.0.1-SNAPSHOT/versionnamedrp-parent/namedescriptionDemo project for Spring Boot/descriptionpropertiesmaven.compiler.source8/maven.compiler.sourcemaven.compiler.target8/maven.compiler.targetproject.build.sourceEncodingUTF-8/project.build.sourceEncodingmaven.compiler.source1.8/maven.compiler.sourcemaven.compiler.target1.8/maven.compiler.targetjunit.version4.12/junit.versionlog4j.version1.2.17/log4j.versionlombok.version1.16.18/lombok.version/propertiesdependencyManagementdependenciesdependencygroupIdorg.springframework.cloud/groupIdartifactIdspring-cloud-dependencies/artifactIdversion2021.0.5/versiontypepom/typescopeimport/scope/dependency/dependencies/dependencyManagementbuildpluginsplugingroupIdorg.apache.maven.plugins/groupIdartifactIdmaven-compiler-plugin/artifactIdversion3.5.1/versionconfigurationsource${maven.compiler.source}/sourcetarget${maven.compiler.target}/target/configuration/plugin/plugins/build/project3.2、创建子公共模块common-api 3.2.1、添加module 3.2.2、pom.xml配置 ?xml version1.0 encodingUTF-8? project xmlnshttp://maven.apache.org/POM/4.0.0xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsdmodelVersion4.0.0/modelVersionparentgroupIdcom.hqyj/groupIdartifactIdSpringCloud/artifactIdversion0.0.1-SNAPSHOT/version/parentartifactIdcommon-api/artifactIdpropertiesmaven.compiler.source8/maven.compiler.sourcemaven.compiler.target8/maven.compiler.targetproject.build.sourceEncodingUTF-8/project.build.sourceEncoding/propertiesdependenciesdependencygroupIdorg.projectlombok/groupIdartifactIdlombok/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 version1.0 encodingUTF-8? project xmlnshttp://maven.apache.org/POM/4.0.0xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsdmodelVersion4.0.0/modelVersionparentgroupIdcom.hqyj/groupIdartifactIdSpringCloud/artifactIdversion0.0.1-SNAPSHOT/version/parentartifactIdeureka-server/artifactIdpropertiesmaven.compiler.source8/maven.compiler.sourcemaven.compiler.target8/maven.compiler.targetproject.build.sourceEncodingUTF-8/project.build.sourceEncodingskip-teststrue/skip-tests/propertiesdependenciesdependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactId/dependencydependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-test/artifactIdscopetest/scope/dependencydependencygroupIdorg.projectlombok/groupIdartifactIdlombok/artifactIdoptionaltrue/optional/dependencydependencygroupIdcom.github.enesusta/groupIdartifactIdspring-devtools/artifactIdversion1.0.1/versionoptionaltrue/optional/dependencydependencygroupIdorg.springframework.cloud/groupIdartifactIdspring-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 version1.0 encodingUTF-8? project xmlnshttp://maven.apache.org/POM/4.0.0xmlns:xsihttp://www.w3.org/2001/XMLSchema-instancexsi:schemaLocationhttp://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsdmodelVersion4.0.0/modelVersionparentgroupIdcom.hqyj/groupIdartifactIdSpringCloud/artifactIdversion0.0.1-SNAPSHOT/version/parentartifactIduser-service/artifactIdpropertiesmaven.compiler.source8/maven.compiler.sourcemaven.compiler.target8/maven.compiler.targetproject.build.sourceEncodingUTF-8/project.build.sourceEncoding/propertiesdependenciesdependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactId/dependency!--devtools 开发工具--dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-devtools/artifactIdscoperuntime/scopeoptionaltrue/optional/dependency!--Spring Boot 测试--dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-test/artifactIdscopetest/scope/dependency!--junit 测试--dependencygroupIdjunit/groupIdartifactIdjunit/artifactIdversion4.12/version/dependency!-- 修改后立即生效热部署 --dependencygroupIdorg.springframework/groupIdartifactIdspringloaded/artifactIdversion1.2.8.RELEASE/version/dependencydependencygroupIdorg.springframework.cloud/groupIdartifactIdspring-cloud-starter-netflix-eureka-client/artifactId/dependencydependencygroupIdcom.hqyj/groupIdartifactIdcommon-api/artifactIdversion0.0.1-SNAPSHOT/version/dependency/dependencies/project3.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、查看编译后的包 小结 Eureka 作为Netflix 公司开发的一款开源的服务注册与发现组件还是十分经典的。在服务注册与发现这一块也是十分优秀有兴趣的同学可以去下载Eureka的源码研究一下看看Eureka是如何实现服务注册调用端是如何发现服务并调用最后再看看Eureka里同一个服务多台机器实例是如何实现负载均衡调用的。
http://www.hkea.cn/news/14384366/

相关文章:

  • 做网站前端需要懂得seo关键词排名优化推荐
  • 百度链接插件 wordpressseo推广营销公司
  • 建娱乐网站百度大数据平台
  • 做问卷用哪个网站做网站行业怎么样
  • 哪里找专业做网站的人网站开发 岗位及职责
  • 广州网站制作信科建设市场调研报告怎么写
  • 十大拿货网站可以推广的软件有哪些
  • 有个做搞笑视频的网站谁能给我一个网址
  • 网站建设需要什么样的内容网站 ftp信息
  • 比较简洁大方的网站免费广告投放平台
  • 鹰潭网站商城建设开发 程序网站
  • 沈阳企业制作网站哪里建个人网站好
  • 维护网站的职位叫什么cms 网站
  • wordpress网站被黑了南昌网站推广策划
  • 麒贺丝网做的网站优化女人网站源码
  • 西安企业网站seo自己开发小程序要多少钱
  • 网站ui设计是什么WordPress出现508
  • 怎样做旅游视频网站织梦 做网站 教程
  • 云南省建设厅官方网站不良记录酒店网站的建设方案
  • 垂直电商网站建设方案青海省建设厅职业注册官方网站
  • wordpress站长主题北京网络推广公司排名
  • 安徽合肥建设银行招聘网站国外搜索引擎大全
  • 安 网站建设word可以做网页
  • 山东建设官方网站wordpress添加页面模块
  • 做网站公司联系方式页面网站设计内容清单
  • 南京网站制作联系宋营销网点机构号
  • 建设网站的岗位专业制作网站用哪些软件
  • 顺企网江西网站建设西安网站建设公司咪豆
  • 做外贸网站那个好网站流量 钱
  • 企业级网站开发酒店网站建设描述