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

网站开发岗位内容和要求微信小程序是什么框架

网站开发岗位内容和要求,微信小程序是什么框架,重庆建设工程安全信息管理网,seo短视频新地址在哪里RestTemplate、WebClient与HttpInterface SpringBoot中集成了很多轻量级的Http客户端 RestTemplate:普通开发WebClient:响应式编程开发HttpInterface:声明式编程 响应式编程介绍 响应式编程#xff08;Reactive Programming#xff09;是一种编程范式#xff0c;用于处理…RestTemplate、WebClient与HttpInterface SpringBoot中集成了很多轻量级的Http客户端 RestTemplate:普通开发WebClient:响应式编程开发HttpInterface:声明式编程 响应式编程介绍 响应式编程Reactive Programming是一种编程范式用于处理异步数据流和事件流。它基于观察者模式和函数式编程的概念通过使用流Stream或者事件Event来处理数据的变化和交互。 在响应式编程中数据流被看作是一个连续的时间序列程序可以订阅这个数据流并对数据的变化做出相应的处理。当数据发生变化时程序会自动更新相关的操作而无需手动干预。 响应式编程具有以下特点 响应式能够对数据流中的变化做出及时响应而无需手动触发。 异步能够处理异步操作如网络请求或用户交互。 延迟执行只有在真正需要结果时才会执行相关操作。 可组合性能够将多个操作组合在一起形成复杂的数据流处理逻辑。 错误处理能够处理异常和错误并提供相应的处理机制。 响应式编程在很多场景下都具有优势例如用户界面的响应性、数据流的处理和分析等。 RestTemplate与WebClient区别 RestTemplate采用同步阻塞的方式运行WebClient采用异步非阻塞的方式运行只用需要WebClient返会的结果时对应的方法才会执行 使用WebClient 引入依赖 dependencygroupIdorg.springframework.boot/groupIdartifactIdspring-boot-starter-webflux/artifactId/dependency构建业务 Service public class CityServiceImpl implements CityService {Overridepublic MonoString query(String city) {WebClient webClient WebClient.create();MapString, String param new HashMap();param.put(city, 西安);return webClient.get().uri(https://wttr.in/{city}?langzh, param).accept(MediaType.ALL).retrieve().bodyToMono(String.class);} }package com.vmware.controller;import com.vmware.service.CityService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; import reactor.core.publisher.Mono;RequestMapping(/city) RestController public class CityController {Autowiredprivate CityService cityService;GetMapping(/{city})public MonoString city(PathVariable String city) throws InterruptedException {MonoString mono cityService.query(city);return query;} } 注意:mono对象被返回之前实际上接口处于未调用状态当返回后延时调用 HttpInterface 介绍:HttpInterfaces是由spring6.0引入的新的http调用方式通过声明接口的方式对http请求进行调用与传统硬编码的方法有所不同依赖于spring-boot-starter-webflux 基本使用 package com.vmware.service;import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.service.annotation.GetExchange; import reactor.core.publisher.Mono;public interface CityWebClientService {GetExchange(url https://wttr.in/{city}?langzh)MonoString getWeather(PathVariable String city); }Overridepublic MonoString queryByWebClient(String city) {WebClient client WebClient.builder().baseUrl(https://wttr.in).codecs(clientCodecConfigurer - {clientCodecConfigurer.defaultCodecs().maxInMemorySize(256 * 1024 * 1024);//修改默认的buffer大小}).build();//创建工厂HttpServiceProxyFactory factory HttpServiceProxyFactory.builder(WebClientAdapter.forClient(client)).build();//创建代理对象CityWebClientService service factory.createClient(CityWebClientService.class);return service.getWeather(city);}工程化使用 将WebClient和HttpServiceProxyFactory使用配置类注入到容器中将对应的WebClient请求接口代理后注入到容器中在对应的业务中进行注入WebClient请求接口 package com.vmware.config;import com.vmware.service.CityWebClientService; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import org.springframework.web.reactive.function.client.WebClient; import org.springframework.web.reactive.function.client.support.WebClientAdapter; import org.springframework.web.service.invoker.HttpServiceProxyFactory;Configuration public class WebClientConfig {/*** apiNote 配置WebClient* return*/Beanpublic WebClient httpServiceProxyFactory() {return WebClient.builder().codecs(clientCodecConfigurer - {clientCodecConfigurer.defaultCodecs().maxInMemorySize(256 * 1024 * 1024);//修改默认的buffer大小}).build();}/*** apiNote 构建 HttpServiceProxyFactory* param client* return*/Beanpublic HttpServiceProxyFactory factory(WebClient client) {//创建工厂return HttpServiceProxyFactory.builder(WebClientAdapter.forClient(client)).build();}/*** apiNote 代理HttpClient接口* param factory* return*/Beanpublic CityWebClientService cityWebClientService(HttpServiceProxyFactory factory) {return factory.createClient(CityWebClientService.class);} }package com.vmware.service.impl;import com.vmware.service.CityService; import com.vmware.service.CityWebClientService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.MediaType; import org.springframework.stereotype.Service; import org.springframework.web.reactive.function.client.WebClient; import org.springframework.web.reactive.function.client.support.WebClientAdapter; import org.springframework.web.service.invoker.HttpServiceProxyFactory; import reactor.core.publisher.Mono;import java.util.HashMap; import java.util.Map;Service public class CityServiceImpl implements CityService {Autowiredprivate CityWebClientService cityWebClientService;Overridepublic MonoString queryByWebClient2(String city) {return cityWebClientService.getWeather(city);} }
http://www.ihoyoo.com/news/19230.html

相关文章:

  • 网站的客户体验做室内意向图的网站
  • 食品网站建设的照片网站建设宣传图片
  • 长沙城乡建设部网站首页不花钱做推广的网站
  • 烟台网站建设企业wordpress注册密码链接失效
  • 获取网站验证码地址嘉兴网站设计999 999
  • 网站建设如何选择域名网站500错误是什么意思
  • 哪个网站域名更新快青岛网站建设微动力
  • 网站流量报告wordpress 单栏模板
  • 电子商务网站建设与维护方法分析不包括哪些建筑方案设计包括什么
  • 建立带数据库的网站怎么建立一个网站卖东西
  • 查询网站dns服务器什么是seo优化?
  • 企业站用什么程序做网站微博搜索引擎优化
  • 企业网站开发主要职责建站 网站程序有哪些
  • 上海哪个网站能应聘做家教的孝感做网站xgsh
  • 三门峡市住房的城乡建设局网站河南省建设厅网站
  • 咖啡厅网站开发目标齐家网装修怎么收费
  • 网站编排同ip多域名做同行业网站
  • 国外做农产品有名的网站有哪些wordpress获取点击量
  • 网站响应度常德网站建设专业品牌
  • 宿迁做网站电话哪个省份网站建设便宜
  • 古董专家官方网站微信商城网站制作深圳网站制作
  • 三合一网站怎么建立wordpress详细安装说明
  • wrix 网站开发哪里制作企业网站
  • 快速学习网站建设wordpress PHP cpanel
  • 找最新游戏做视频网站有哪些wordpress 菜单无法保存
  • 来凤县住房和城乡建设厅网站html网页基本结构
  • 湖北联兴建设有限公司网站温猛设计工作室
  • 游戏网站怎么赚钱做网站没有数据
  • 药材网技术网站建设辽宁建设工程信息网招标
  • 站内站怎么搭建电子商务网站建设的体会