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

网站建设和优化的好处天猫优惠券网站怎么做的

网站建设和优化的好处,天猫优惠券网站怎么做的,西安网站建设案例,网站免费下载安装关于Spring Cloud Open Feign的介绍可以参考这两篇博客 OpenFeign服务接口调用 使用Feign作为服务消费者 本博客参考gitee开源项目代码#xff0c;结合自己的理解#xff0c;记录下微服务场景下的使用。Talk is cheap. Show me the code#xff01; 一、项目结构 这里使用…关于Spring Cloud Open Feign的介绍可以参考这两篇博客 OpenFeign服务接口调用 使用Feign作为服务消费者 本博客参考gitee开源项目代码结合自己的理解记录下微服务场景下的使用。Talk is cheap. Show me the code 一、项目结构 这里使用eureka作为注册中心,person和equipment两个web服务作为业务中台本例中会使用postman调用person服务person服务中调用equipment服务。 registry -- 注册中心(当前采用eureka) person -- 人员服务person-api -- 人员相关api提供, 包括 req, resp, service 等person-biz -- 人员相关服务接口具体实现, 依赖person-apiperson-provider -- 人员相关微服务启动类, 依赖person-biz equipment -- 设备服务equipment-api -- 设备相关api提供, 包括 req, resp, service 等equipment-biz -- 设备相关服务接口具体实现, 依赖equipment-apiequipment-provider -- 设备相关微服务启动类, 依赖equipment-biz源码下载地址欢迎star springboot-openfeign 二、registry – 注册中心(当前采用eureka) 1、application.yml server:port: 8001 # 该服务端口eureka:instance:hostname: registry # eureka的实例名称client:registerWithEureka: false # false表示当前项目不以客户端注册到服务中心(因为该项目本身就是注册中心)fetchRegistry: false # false表示当前项目不需要从注册中心拉取服务配置(因为该项目本身就是注册中心)serviceUrl:defaultZone: http://localhost:8001/eureka/spring:application:name: server-registy # 当前项目的实例名称(很重要)2、核心pom.xml !-- 引入eureka-server依赖 --dependencygroupIdorg.springframework.cloud/groupIdartifactIdspring-cloud-starter-netflix-eureka-server/artifactIdversion2.1.3.RELEASE/version/dependency!-- gson --dependencygroupIdcom.google.code.gson/groupIdartifactIdgson/artifactIdversion2.6.2/version/dependency3、主启动类RegistryApplication SpringBootApplication EnableEurekaServer public class RegistryApplication {public static void main(String[] args) {SpringApplication.run(RegistryApplication.class, args);} }三、person – 人员服务 1、application.yml server:port: 8002spring:application:name: person-providereureka:client:serviceUrl:defaultZone: http://localhost:8001/eureka/feign:httpclient:enabled: true2、核心pom.xml cloud-person-provider dependencygroupIdorg.springframework.cloud/groupIdartifactIdspring-cloud-starter-netflix-eureka-client/artifactIdversion2.2.1.RELEASE/version /dependencycloud-person-biz !-- 使用web --dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactIdversion2.2.1.RELEASE/version/dependency!-- person-api --dependencygroupIdtca/groupIdartifactIdcloud-person-api/artifactIdversion1.0.0/version/dependency!-- equipment-api --dependencygroupIdtca/groupIdartifactIdcloud-equipment-api/artifactIdversion1.0.0/version/dependencycloud-person-api !-- openFeign --dependencygroupIdorg.springframework.cloud/groupIdartifactIdspring-cloud-starter-openfeign/artifactIdversion2.2.1.RELEASE/version/dependency3、PersonFeign和PersonController FeignClient(value person-provider) public interface PersonFeign {/*** 根据id获取人员* param personReq* return*/PostMapping(/person/get)PersonResp get(PersonReq personReq); }RestController RequestMapping(value /person) Slf4j public class PersonController {Autowiredprivate EquipmentFeign equipmentFeign;/*** 获取人员* param personReq* return*/PostMapping(/get)public PersonResp get(Validated RequestBody PersonReq personReq) {PersonResp personResp new PersonResp();personResp.setId(personReq.getId());personResp.setAge(30);personResp.setName(Messi);EquipmentReq equipmentReq new EquipmentReq();equipmentReq.setId(personReq.getId());EquipmentResp equipmentResp equipmentFeign.get(equipmentReq);log.info(equipmentResp {}, equipmentResp);return personResp;} }4、项目结构 四、equipment – 设备服务 1、application.yml server:port: 8003spring:application:name: equipment-providereureka:client:serviceUrl:defaultZone: http://localhost:8001/eureka/2、核心pom.xml cloud-equipment-api !-- openFeign --dependencygroupIdorg.springframework.cloud/groupIdartifactIdspring-cloud-starter-openfeign/artifactIdversion2.2.1.RELEASE/version/dependencycloud-equipment-biz !-- 使用web --dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactIdversion2.2.1.RELEASE/version/dependency!-- equipment-api --dependencygroupIdtca/groupIdartifactIdcloud-equipment-api/artifactIdversion1.0.0/version/dependency!-- person-api --dependencygroupIdtca/groupIdartifactIdcloud-person-api/artifactIdversion1.0.0/version/dependencycloud-equipment-provider dependencygroupIdtca/groupIdartifactIdcloud-equipment-biz/artifactIdversion1.0.0/version/dependencydependencygroupIdorg.springframework.cloud/groupIdartifactIdspring-cloud-starter-netflix-eureka-client/artifactIdversion2.2.1.RELEASE/version/dependency3、EquipmentFeign和EquipmentController FeignClient(value equipment-provider) public interface EquipmentFeign {/*** 根据id获取人员* param equipmentReq* return*/PostMapping(/equipment/get)EquipmentResp get(EquipmentReq equipmentReq); }RestController RequestMapping(value /equipment) Slf4j public class EquipmentController {Autowiredprivate PersonFeign personFeign;/*** 获取人员* param equipmentReq* return*/PostMapping(/get)public EquipmentResp get(Validated RequestBody EquipmentReq equipmentReq) {EquipmentResp equipmentResp new EquipmentResp();equipmentResp.setId(equipmentReq.getId());equipmentResp.setName(平板设备);return equipmentResp;} }4、项目结构 五、测试 分别启动这三个服务 利用postman访问localhost:8002/person/get其中body中id传不同参数进行测试 可以发现能够通过openfeign在微服务之间进行接口调用
http://www.hkea.cn/news/14263897/

相关文章:

  • 建设部网站 自住房佛山网站制作
  • 南京网站设计公司兴田德润放心做网站推广每天加班
  • 佛山网站建设设计公司哪家好北海网站制作公司
  • 秦皇岛工程建设信息网站wordpress弱口令字典
  • 上海医疗 网站制作兰州网站seo外包
  • 做网站知识点江苏建设工程交易中心网站
  • 沈阳网站seo公司现代装修风格2022年
  • 青州哪里做网站贵阳网站如何推广
  • 西安西部数码备案网站wordpress 小说连载
  • 石家庄做外贸网站美业营销策划公司
  • 营销型网站建设公司提供网站建设移动云盘免费空间
  • 网站建设 手机app如何加强网站管理的队伍建设
  • 自己建立网站服务器wordpress分类目录多级菜单
  • 网站建设分为哪几部分苏州惊天网站制作网
  • 网站开发人员结构配比海南澄迈网站建设
  • 网站建设制作公司地址网站的建设需要多少
  • 网站中在线咨询怎么做大连建设公司网站
  • 手表网站哪家好wordpress兼容mip
  • 网站开发的3个阶段制作app需要哪些知识
  • 400网站建设办公服装设计学校十大排名
  • 做网站有一个火箭回顶部山西搜索引擎优化
  • 龙岗同乐社区网站建设短视频app成品搭建源码免费
  • 建站教程流程图网站建设gxjzdrj
  • 湖南it网站建设mxtia域名空间做网站
  • 手机wap网站开发微网站 微信网站
  • wordpress室内设计哈尔滨百度网站快速优化
  • 网站系统架构图做网站的桔子什么
  • 邓亚萍做的网站关于新农村网络建设网站
  • 旅游网站建设目标长沙网页设计培训服务好长沙大计校区
  • 做的网站第二年续费多钱平面设计师工作内容