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

网站建设公司哪家好服装网站建设比较好

网站建设公司哪家好,服装网站建设比较好,贵州网站开发流程,属于免费的网络营销方式Spring Cloud中集成Feign (只是笔记而已 其中有点命名啥的不对应#xff0c;搜到了就划走吧) Feign--[feɪn]#xff1a;Web 服务客户端#xff0c;能够简化 HTTP 接口的调用。 没有Feign的之前服务提供者 package com.springcloudprovide.controller;import com.springclo…Spring Cloud中集成Feign (只是笔记而已 其中有点命名啥的不对应搜到了就划走吧) Feign--[feɪn]Web 服务客户端能够简化 HTTP 接口的调用。 没有Feign的之前服务提供者 package com.springcloudprovide.controller;import com.springcloudprovide.service.UserName; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController;RestController public class UserController {Autowiredprivate UserName userName;RequestMapping(username)public String getUserName(){return userName.getUsername();} }服务消费者通过RestTemplate来调用服务提供者的服务接口 package com.springcloudconsumer.tempalte;import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.web.client.RestTemplate;Configuration public class RestTemplateConfiguration {BeanLoadBalancedpublic RestTemplate getRestTmplate(){return new RestTemplate();} }package com.springcloudconsumer.controller;import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.client.RestTemplate;RestController public class UserBeanController {Autowiredprivate RestTemplate restTemplate;RequestMapping(/showName)public String getUserName(){System.out.println(123);return restTemplate.getForObject(http://localhost:8081/username, String.class);} }Feign的使用 创建基于Eureka模块的注册中心和服务提供者 基于Feign的服务消费者 dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-web/artifactId/dependencydependencygroupIdorg.springframework.cloud/groupIdartifactIdspring-cloud-starter-netflix-eureka-client/artifactIdversion3.0.2/version/dependency!-- openfeign--dependencygroupIdorg.springframework.cloud/groupIdartifactIdspring-cloud-starter-openfeign/artifactIdversion3.0.2/version/dependency 定义Feign的客户端接口 package com.springcloud.feign.service;import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.RequestMapping;FeignClient(value eurekaprovider) public interface UserServiceFeign {RequestMapping(username)public String getUserName(); }这个注解FeignClient标识当前是一个 Feign 的客户端value 属性是对应的服务名称也就是你需要调用哪个服务中的接口。 创建服务消费者的控制类 package com.wangxing.eurekacomsumer.eurekacomsumerdemo.controller; import com.wangxing.eurekacomsumer.eurekacomsumerdemo.serviceclient.UserFeignClient; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; RestController public class UserBeanController {//注入一个Feign的客户端对象Autowiredprivate UserFeignClient userFeignClient;RequestMapping(/showName.do)public String getUserName(){return userFeignClient.getUserName();} } 配置主类 package com.springcloud.feign;import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.netflix.hystrix.EnableHystrix; import org.springframework.cloud.openfeign.EnableFeignClients;SpringBootApplication EnableHystrix EnableFeignClients public class SpringcloudFeignApplication {public static void main(String[] args) {SpringApplication.run(SpringcloudFeignApplication.class, args);}}如果你的 Feign 接口定义跟你的启动类不在同一个包名下还需要制定扫描的包名 EnableFeignClientsbasePackages“com.fangjia.api.client” 通过跟之前的代码相比可以发现我们的调用方式变得越来越简单了从最开始的指定地址到后面通过 Eureka 中的服务名称来调用再到现在直接通过定义接口来调用。 Feign 提供了很多的扩展机制让用户可以更加灵活的使用这节我们来学习 Feign 的一些自定义配置。 使用配置自定义 Feign 的配置 除了使用代码的方式来对 Feign 进行配置我们还可以通过配置文件的方式来指定 Feign 的配置。 # 链接超时时间 feign.client.config.feignName.connectTimeout5000 # 读取超时时间 feign.client.config.feignName.readTimeout5000 # 日志等级 feign.client.config.feignName.loggerLevelfull # 重试 feign.client.config.feignName.retryercom.example.SimpleRetryer # 拦截器 feign.client.config.feignName.requestInterceptors[0]com.example.FooRequestInterceptor feign.client.config.feignName.requestInterceptors[1]com.example.BarRequestInterceptor # 编码器 feign.client.config.feignName.encodercom.example.SimpleEncoder # 解码器 feign.client.config.feignName.decodercom.example.SimpleDecoder # 契约 feign.client.config.feignName.contractcom.example.SimpleContract
http://www.hkea.cn/news/14528938/

相关文章:

  • 简述网站制作流程wdcp网站无法访问
  • 网站关键词怎么优化排名主做熟人推荐的招聘网站
  • 网站建设合同有法律效益吗山西建设机械网站首页
  • 长春专业企业网站建设价格网站建设网站备案所需资料
  • 天津做宠物饲料的网站呼和浩特公司做网站
  • 绍兴企业网站开发注册360建筑网平台
  • 微信订单网站模版网站设计方案图
  • iis网站重定向网站制作方案大全
  • python做后台开发移动网站主题网站设计实验步骤
  • 有些网站勤换域名怎么搭建源码网站
  • 优质网站建设廉政网站建设的意义
  • 网站建设的基本流程是怎样的手机上如何制作自己的网站
  • 怎么做支付网站数据中台系统
  • 社交博客网站开发国外网站的分析工具有哪些
  • 做网站怎么选择上市公司成都美誉网站设计
  • 硅胶 技术支持 东莞网站建设虚拟网站怎么做
  • windows server iis 添加网站泰州市做网站
  • 手机网站开发用什么服装设计公司排行榜
  • 网站怎么升级网络推广团队分工
  • 如何推广外贸型网站linux做网站要多大内存
  • 孝感房产网站建设亿网联播
  • 做一个在线支付网站做杂志的网站
  • 站长友情链接平台yzipi主题wordpress
  • 苏州做网站的单位模板王怎么下载字体
  • 成都网站建设贴吧推广公司文案
  • 室内设计资料网站福田欧马可
  • 怎么做彩票网站代理如何做好品牌网站建设策划
  • 自适应网站欣赏在线咨询妇科医生免费
  • 万网注册的域名怎么建设网站学校网站怎么做优化
  • 长沙做网站多少钱织梦网站地图在线生成