httpclient工具类(支持泛型转换)

1、网上搜到的httpclient工具类的问题:

1.1、如下图我们都能够发现这种封装的问题:

  • 代码繁杂、充斥了很多重复性代码
  • 返回值单一,无法拿到对应的Java Bean对象及List对象集合
  • 实际场景中会对接大量第三方的OPEN API,下述方法的扩展性差

在这里插入图片描述

1.2、简洁调用方式演示

本文基于上述问题,通过设计模式、泛型、JSON工具类的方式进行了封装,得到了下述更方便、更简洁的http请求调用方式

Entity params = new Entity();
params.setUrl("/common/postJson");Map<String, Object> map = new HashMap<>();
map.put("userId", "13277887788");
map.put("companyId", "87037827534cf");
params.setParams(map);// 返回对象集合
List<AppEntity> appEntity = thirdHttpProcessorFactory.doGetReturnList(ThirdSystemEnum.ION, params, AppEntity.class);
// 返回String类型
String result = thirdHttpProcessorFactory.doGetReturnBean(ThirdSystemEnum.ION, params, String.class);
// 返回指定的对象
AppEntity appEntity = thirdHttpProcessorFactory.doGetReturnBean(ThirdSystemEnum.ION, params, AppEntity.class);

1.3、 目录结构

在这里插入图片描述

2、引入的maven仓库

 <dependency><groupId>com.fasterxml.jackson.core</groupId><artifactId>jackson-databind</artifactId><version>2.14.2</version>
</dependency>
<dependency><groupId>cn.hutool</groupId><artifactId>hutool-all</artifactId><version>5.7.16</version>
</dependency>
  • ThirdHttpProcessorFactory:存储不同三方平台的处理期
  • ThirdHttpProcessor:定义通用的接口
  • AbstractThirdHttpProcessor:定义公共的处理逻辑
  • IonHttpProcessor:定义各对接平台的差异性逻辑
  • AppEntity:返回值
  • Entity:入参
  • ThirdSystemEnum:定义三方平台的枚举

3、代码实现

3.1、获取不同第三方处理器的工厂ThirdHttpProcessorFactory

package com.ionrocking.platform.tripartite;import com.ionrocking.common.core.exception.ServiceException;
import com.ionrocking.platform.tripartite.entity.Entity;
import com.ionrocking.platform.tripartite.enums.ThirdSystemEnum;
import lombok.experimental.Accessors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.List;
import java.util.Map;/*** @author ke* Created by on  2023-10-27 15:23*/
@Component
@Accessors(chain = true)
public class ThirdHttpProcessorFactory {@Autowiredprivate List<ThirdHttpProcessor> thirdHttpProcessors;private Map<String, ThirdHttpProcessor> thirdHttpProcessorMap;@PostConstructpublic void init() {if (CollectionUtils.isEmpty(thirdHttpProcessors)) {return;}thirdHttpProcessorMap = new HashMap<>(8);for (ThirdHttpProcessor processor : thirdHttpProcessors) {thirdHttpProcessorMap.put(processor.getType().getCode(), processor);}}private ThirdHttpProcessor getThirdHttpProcessor(String type) {ThirdSystemEnum thirdSystemEnum = ThirdSystemEnum.getByCode(type);if (null == thirdSystemEnum) {throw new ServiceException("三方OpenApi尚未配置,无法进行请求");}return thirdHttpProcessorMap.get(type);}/*** http get请求** @param thirdSystemEnum 三方系统类型枚举* @param entity          参数* @param tClass          返回参数类型* @return T              返回数据对象* @throws Exception 业务执行异常*/public <T> T doGetReturnBean(ThirdSystemEnum thirdSystemEnum, Entity entity, Class<T> tClass) throws Exception {return getThirdHttpProcessor(thirdSystemEnum.getCode()).doGetReturnBean(entity, tClass);}/*** http post请求,入参支持application/x-www-form-urlencoded 请求** @param thirdSystemEnum 三方系统类型枚举* @param entity          参数* @param tClass          返回参数类型* @return T              返回数据对象* @throws Exception 业务执行异常*/public <T> T doPostReturnBean(ThirdSystemEnum thirdSystemEnum, Entity entity, Class<T> tClass) throws Exception {return getThirdHttpProcessor(thirdSystemEnum.getCode()).doPostReturnBean(entity, tClass);}/*** http post请求,入参支持application/json请求** @param thirdSystemEnum 三方系统类型枚举* @param entity          参数* @param tClass          返回参数类型* @return T              返回数据对象* @throws Exception 业务执行异常*/public <T> T doPostJsonReturnBean(ThirdSystemEnum thirdSystemEnum, Entity entity, Class<T> tClass) throws Exception {return getThirdHttpProcessor(thirdSystemEnum.getCode()).doPostJsonReturnBean(entity, tClass);}/*** http get请求** @param thirdSystemEnum 三方系统类型枚举* @param entity          参数* @param tClass          返回参数类型* @return List<T>        返回数据集合* @throws Exception 业务执行异常*/public <T> List<T> doGetReturnList(ThirdSystemEnum thirdSystemEnum, Entity entity, Class<T> tClass) throws Exception {return getThirdHttpProcessor(thirdSystemEnum.getCode()).doGetReturnList(entity, tClass);}/*** http post请求,入参支持application/x-www-form-urlencoded 请求** @param thirdSystemEnum 三方系统类型枚举* @param entity          参数* @param tClass          返回参数类型* @return List<T>        返回数据集合* @throws Exception 业务执行异常*/public <T> List<T> doPostReturnList(ThirdSystemEnum thirdSystemEnum, Entity entity, Class<T> tClass) throws Exception {return getThirdHttpProcessor(thirdSystemEnum.getCode()).doPostReturnList(entity, tClass);}/*** http post请求,入参支持application/json请求** @param thirdSystemEnum 三方系统类型枚举* @param entity          参数* @param tClass          返回参数类型* @return List<T>        返回数据集合* @throws Exception 业务执行异常*/public <T> List<T> doPostJsonReturnList(ThirdSystemEnum thirdSystemEnum, Entity entity, Class<T> tClass) throws Exception {return getThirdHttpProcessor(thirdSystemEnum.getCode()).doPostJsonReturnList(entity, tClass);}}

3.2、http请求处理的接口ThirdHttpProcessor

/*** Dans.com Inc.* Copyright (c) 2011-2020 All Rights Reserved*/
package com.ionrocking.platform.tripartite;import com.ionrocking.platform.tripartite.entity.Entity;
import com.ionrocking.platform.tripartite.enums.ThirdSystemEnum;import java.util.List;/*** 追踪事件处理器** @author ke* Created by on  2023-06-20 15:23*/
public interface ThirdHttpProcessor {/*** 业务执行** @param entity* @param tClass* @return T* @throws Exception 业务执行异常*/<T> T doGetReturnBean(Entity entity, Class<T> tClass) throws Exception;/*** 业务执行** @param entity* @param tClass* @return* @throws Exception 业务执行异常*/<T> T doPostReturnBean(Entity entity, Class<T> tClass) throws Exception;/*** 业务执行** @param entity* @param tClass* @return* @throws Exception 业务执行异常*/<T> T doPostJsonReturnBean(Entity entity, Class<T> tClass) throws Exception;/*** 业务执行** @param entity* @param tClass* @return T* @throws Exception 业务执行异常*/<T> List<T> doGetReturnList(Entity entity, Class<T> tClass) throws Exception;/*** 业务执行** @param entity* @param tClass* @return* @throws Exception 业务执行异常*/<T> List<T> doPostReturnList(Entity entity, Class<T> tClass) throws Exception;/*** 业务执行** @param entity* @param tClass* @return* @throws Exception 业务执行异常*/<T> List<T> doPostJsonReturnList(Entity entity, Class<T> tClass) throws Exception;/*** 获取事件类型** @return*/ThirdSystemEnum getType();
}

3.3、通用逻辑处理的抽象类AbstractThirdHttpProcessor

  • 如在通过http client发起HTTP请求时,除了请求头requestHeader、请求入参requestBody不同,其他逻辑都是一样的,则可以进行公共代码的抽取
  • 如果存在特殊的逻辑处理,则可以在子类中重写父类的方法
package com.ionrocking.platform.tripartite;import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONUtil;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.ionrocking.common.core.exception.ServiceException;
import com.ionrocking.platform.config.SysNacosConfig;
import com.ionrocking.platform.tripartite.entity.Entity;
import com.ionrocking.platform.tripartite.entity.IonResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;/*** @author ke* @Date 2023/10/27*/
@Slf4j
@Component
public abstract class AbstractThirdHttpProcessor implements ThirdHttpProcessor {@Overridepublic <T> List<T> doGetReturnList(Entity entity, Class<T> tClass) throws Exception {// 构造请求头Map<String, String> requestHead = constructRequestHead(entity);// 构造请求数据Map<String, Object> requestBody = constructRequestBody(entity);String result = HttpUtil.createGet(sysNacosConfig.getIonRequestUrl() + entity.getUrl()).addHeaders(requestHead).form(requestBody).execute().body();return toList(result, tClass);}@Overridepublic <T> List<T> doPostReturnList(Entity entity, Class<T> tClass) throws Exception {// 构造请求头Map<String, String> requestHead = constructRequestHead(entity);// 构造请求数据Map<String, Object> requestBody = constructRequestBody(entity);String result = HttpUtil.createPost(sysNacosConfig.getIonRequestUrl() + entity.getUrl()).addHeaders(requestHead).form(requestBody).execute().body();return toList(result, tClass);}@Overridepublic <T> List<T> doPostJsonReturnList(Entity entity, Class<T> tClass) throws Exception {// 构造请求头Map<String, String> requestHead = constructRequestHead(entity);// 构造请求数据Map<String, Object> requestBody = constructRequestBody(entity);String result = HttpUtil.createPost(sysNacosConfig.getIonRequestUrl() + entity.getUrl()).addHeaders(requestHead).body(JSONUtil.toJsonStr(requestBody)).execute().body();return toList(result, tClass);}public <T> T toBean(String result, Class<T> tClass) throws Exception {ObjectMapper objectMapper = new ObjectMapper();IonResponse<Object> response = JSONUtil.toBean(result, IonResponse.class);if (CODE != response.getCode()) {throw new ServiceException(response.getMsg());}if (null == response.getData()) {return null;}return objectMapper.readValue(response.getData().toString(), tClass);}public <T> List<T> toList(String result, Class<T> tClass) throws JsonProcessingException {List<T> data = new ArrayList<>();IonResponse<List<Object>> response = JSONUtil.toBean(result, IonResponse.class);if (CODE != response.getCode()) {throw new ServiceException(response.getMsg());}if (CollUtil.isEmpty(response.getData())) {return null;}for (Object o : response.getData()) {ObjectMapper objectMapper = new ObjectMapper();data.add(objectMapper.readValue(o.toString(), tClass));}return data;}@Resourceprotected SysNacosConfig sysNacosConfig;protected static final int CODE = 200;@Overridepublic <T> T doGetReturnBean(Entity entity, Class<T> tClass) throws Exception {// 构造请求头Map<String, String> requestHead = constructRequestHead(entity);// 构造请求数据Map<String, Object> requestBody = constructRequestBody(entity);String result = HttpUtil.createGet(sysNacosConfig.getIonRequestUrl() + entity.getUrl()).addHeaders(requestHead).form(requestBody).execute().body();return toBean(result, tClass);}/*** 执行** @return*/@Overridepublic <T> T doPostReturnBean(Entity entity, Class<T> tClass) throws Exception {// 构造请求头Map<String, String> requestHead = constructRequestHead(entity);// 构造请求数据Map<String, Object> requestBody = constructRequestBody(entity);String result = HttpUtil.createPost(sysNacosConfig.getIonRequestUrl() + entity.getUrl()).addHeaders(requestHead).form(requestBody).execute().body();return toBean(result, tClass);}@Overridepublic <T> T doPostJsonReturnBean(Entity entity, Class<T> tClass) throws Exception {// 构造请求头Map<String, String> requestHead = constructRequestHead(entity);// 构造请求数据Map<String, Object> requestBody = constructRequestBody(entity);String result = HttpUtil.createPost(sysNacosConfig.getIonRequestUrl() + entity.getUrl()).addHeaders(requestHead).body(JSONUtil.toJsonStr(requestBody)).execute().body();return toBean(result, tClass);}/*** 构造请求头** @param entity* @return*/public abstract Map<String, String> constructRequestHead(Entity entity);/*** 构造请求体** @param entity* @return*/public Map<String, Object> constructRequestBody(Entity entity) {if (CharSequenceUtil.isBlank(entity.getUrl())) {throw new ServiceException("请求路径不能为空");}if (null == entity) {return null;}return entity.getParams();}}

3.4、第三方非通用逻辑处理类IonHttpProcessor

  • 比如此处对接的xx公司需要进行access_token获取及验证,然后将access_token放在请求头中
package com.ionrocking.platform.tripartite.impl;import cn.hutool.core.lang.TypeReference;
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONUtil;
import com.ionrocking.platform.tripartite.AbstractThirdHttpProcessor;
import com.ionrocking.platform.tripartite.entity.Entity;
import com.ionrocking.platform.tripartite.entity.IonResponse;
import com.ionrocking.platform.tripartite.enums.ThirdSystemEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;import java.util.HashMap;
import java.util.Map;/*** @author ke* @Date 2023/10/27*/
@Slf4j
@Component
public class IonHttpProcessor extends AbstractThirdHttpProcessor {private String accessTokenUrl = "/token/getAccessToken";private static final String ACCESS_TOKEN_KEY = "access_token";@Overridepublic Map<String, String> constructRequestHead(Entity entity) {Map<String, String> header = new HashMap<>(2);Map<String, Object> params = new HashMap<>(4);params.put("appId", sysNacosConfig.getIonRequestAppId());params.put("appSecret", sysNacosConfig.getIonRequestAppSecret());String result = HttpUtil.get(sysNacosConfig.getIonRequestUrl() + accessTokenUrl, params);if (CharSequenceUtil.isEmpty(result)) {return null;}TypeReference<IonResponse<Map<String, Object>>> typeRef = new TypeReference<IonResponse<Map<String, Object>>>() {};IonResponse<Map<String, Object>> response = JSONUtil.toBean(result, typeRef, false);if (CODE == response.getCode() && null != response.getData()) {if (response.getData().containsKey(ACCESS_TOKEN_KEY)) {header.put(ACCESS_TOKEN_KEY, response.getData().get(ACCESS_TOKEN_KEY).toString());}}return header;}@Overridepublic ThirdSystemEnum getType() {return ThirdSystemEnum.ION;}
}

3.5、枚举类ThirdSystemEnum

  • 区分不同的平台,根据枚举获取不同的实现类
package com.ionrocking.platform.tripartite.enums;import org.apache.commons.lang3.StringUtils;/*** @author ke* @Date 2023/10/27*/
public enum ThirdSystemEnum {/*** XX科技公司*/ION("ion", "xx科技");private final String code;private final String name;public String getName() {return this.name;}public String getCode() {return this.code;}ThirdSystemEnum(String code, String name) {this.code = code;this.name = name;}public static ThirdSystemEnum getByCode(String code) {if (StringUtils.isEmpty(code)) {return null;}for (ThirdSystemEnum codeEnum : values()) {if (code.equals(codeEnum.getCode())) {return codeEnum;}}return null;}
}

3.6、第三方返回格式对象IonResponse

package com.ionrocking.platform.tripartite.entity;import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;import java.io.Serializable;/*** @author ke* @Date 2023/10/27*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class IonResponse<T> implements Serializable {private static final long serialVersionUID = -8741972144218822267L;private int code;/*** 消息*/private String msg;/*** 数据*/private T data;/*** 总记录数*/private long total;
}

3.7、处理器入参对象Entity

  • 此处定义请求的URL和请求的参数
package com.ionrocking.platform.tripartite.entity;import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;import java.io.Serializable;
import java.util.Map;/*** @author ke* @Date 2023/10/27*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class Entity implements Serializable {private static final long serialVersionUID = -6083780287057302816L;private String url;/*** 参数*/private Map<String, Object> params;
}

3.8、第三方接口返回值对象AppEntity

package com.ionrocking.platform.tripartite.entity;import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;import javax.validation.constraints.NotBlank;/*** @author ke* @Date 2023/10/26*/@Data
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
public class AppEntity {private long id;private String appId;@NotBlank(message = "应用名称不能为空")private String appName;private String appSecret;private String accessToken;private Integer isFlag;
}

3.9、Nacos配置

  • Nacos中一般存放一些第三方的请求域名、鉴权的appId、appSecret等
tripartite-platform:ion:request:url: http://localhost:8080/api/appId: YodeqWwpappSecret: 87037827534cf848a570fae3c93a2469fa0262935af531dddfe7a52ae7f98f41
package com.ionrocking.platform.config;import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;/*** nacos配置信息* @author ke* @Date 2023/9/20*/
@Component
public class SysNacosConfig {@Value("${upload.path}")private String uploadPath;@Value("${tripartite-platform.ion.request.url}")private String ionRequestUrl;@Value("${tripartite-platform.ion.request.appId}")private String ionRequestAppId;@Value("${tripartite-platform.ion.request.appSecret}")private String ionRequestAppSecret;public String getUploadPath() {return uploadPath;}public String getIonRequestUrl() {return ionRequestUrl;}public String getIonRequestAppId() {return ionRequestAppId;}public String getIonRequestAppSecret() {return ionRequestAppSecret;}
}

测试

@RestController
@RequestMapping("/test")
public class Test {@Resourceprivate SysNacosConfig sysNacosConfig;@Resourceprivate ThirdHttpProcessorFactory thirdHttpProcessorFactory;@ResponseBody@RequestMapping(value = "/get")public AjaxResult get() throws Exception extends BaseController  {Entity params = new Entity();params.setUrl("/common/get");String result = thirdHttpProcessorFactory.doGetReturnBean(ThirdSystemEnum.ION, params, String.class);return AjaxResult.success(result);}@ResponseBody@RequestMapping(value = "/list")public AjaxResult list() throws Exception {Entity params = new Entity();params.setUrl("/common/list");List<AppEntity> appEntity = thirdHttpProcessorFactory.doGetReturnList(ThirdSystemEnum.ION, params, AppEntity.class);return AjaxResult.success(appEntity);}@ResponseBody@RequestMapping(value = "/postJson")public AjaxResult postJson() throws Exception {Entity params = new Entity();params.setUrl("/common/postJson");Map<String, Object> map = new HashMap<>();map.put("appId", "YodeqWwp");map.put("appSecret", "87037827534cf848a570fae3c93a2469fa0262935af531dddfe7a52ae7f98f41");params.setParams(map);List<AppEntity> list = thirdHttpProcessorFactory.doPostJsonReturnList(ThirdSystemEnum.ION, params, AppEntity.class);return AjaxResult.success(list);}
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/130456.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

zookeeper集群搭建

zookeeper&#xff08;动物园管理员&#xff09;是一个广泛应用于分布式服务提供协调服务Apache的开源框架 Zookeeper从设计模式角度来理解&#xff1a;是一个基于观察者模式设计的分布式服务管理框架&#xff0c;它 负责存储和管理大家都关心的数据 &#xff0c;然 后 接受观察…

第 04 章_逻辑架构

第 04 章_逻辑架构 1. 逻辑架构剖析 1. 1 服务器处理客户端请求 那服务器进程对客户端进程发送的请求做了什么处理&#xff0c;才能产生最后的处理结果呢&#xff1f;这里以查询请求为 例展示&#xff1a; 下面具体展开看一下&#xff1a; 1.2 Connectors 1.3 第 1 层&…

Docker网络模式_Docker常用命令_以及Docker如何给运行的镜像内容连接互联网_Docker网络模式原理---Docker工作笔记004

然后我们来看一下docker的网络模式: 这个docker我们先看一下电脑上的网络,有两个,1个是lo是测试用的一个是enp0s3这个是我们以太网地址,然后我们去: 安装docker 安装后我们再去ip address可以看到多出来一个网络是docker0 这里ip地址是172.17.0.1这个是私有地址外部无法访问 这…

VSCode实用远程主机功能

作为嵌入式开发者&#xff0c;经常在各种系统平台或者开发工具之间切换&#xff0c;比如你的代码在Linux虚拟机上&#xff0c;如果不习惯在Linux下用IDE&#xff0c;那么我尝试将Linux的目录通过samba共享出来&#xff0c;在windows下用网络映射盘的方式映射出来&#xff0c;VS…

Python某建筑平台数据, 实现网站JS逆向解密

嗨喽&#xff0c;大家好呀~这里是爱看美女的茜茜呐 环境使用: 首先我们先来安装一下写代码的软件&#xff08;对没安装的小白说&#xff09; Python 3.8 / 编译器 Pycharm 2021.2版本 / 编辑器 专业版是付费的 <文章下方名片可获取魔法永久用~> 社区版是免费的 模块…

Java Web 学习笔记(二) —— JDBC

目录 1 JDBC 概述2 JDBC 快速入门3 JDBC API 详解3.1 DriverManager3.2 Connection3.3 Statement3.4 ResultSet3.5 PreparedStatement3.5.1 代码模拟 SQL 注入3.5.2 PreparedStatement 的使用3.5.3 PreparedStatement 原理 4 数据库连接池4.1 数据库连接池概述4.2 数据库连接池…

佳易王配件进出库开单打印进销存管理系统软件下载

用版配件进出库开单打印系统&#xff0c;可以有效的管理&#xff1a;供货商信息&#xff0c;客户信息&#xff0c;进货入库打印&#xff0c;销售出库打印&#xff0c;进货明细或汇总统计查询&#xff0c;销售出库明细或汇总统计查询&#xff0c;库存查询&#xff0c;客户往来账…

NodeJS 安装及环境配置

下载地址&#xff1a;https://nodejs.org/zh-cn/download/ 安装 NodeJS 根据自己电脑系统及位数选择&#xff0c;一般都选择 windows 64位 .msi 格式安装包。 所用命令&#xff1a; node -v npm -v PS&#xff1a;如果以上两条命令都能执行成功&#xff0c;表示安装完成&#…

stable diffusion公司发布4款LLM大语言模型,为何大家都喜爱LLM?

stable diffusion模型是Stability AI开源的一个text-to-image的扩散模型&#xff0c;其模型在速度与质量上面有了质的突破&#xff0c;玩家们可以在自己消费级GPU上面来运行此模型&#xff0c;本模型基于CompVis 和 Runway 团队的Latent Diffusion Models。本期我们不介绍stabl…

Java自学第4课:Java数组,类,对象

1 一维数组的创建和使用 2种创建形式&#xff1a; &#xff08;1&#xff09;先声明&#xff0c;再用new分配内存 &#xff08;2&#xff09;声明的同时分配内存 2种幅值形式 &#xff08;1&#xff09;用new{}赋值 &#xff08;2&#xff09;用{}赋值 如果不使用的话&a…

apb介绍

https://www.cnblogs.com/xianyuIC/p/17279209.html***带testbench https://zhuanlan.zhihu.com/p/623829190?utm_id0 https://zhuanlan.zhihu.com/p/607964532带testbench by四人独行 https://blog.csdn.net/weixin_40377195/article/details/124899571 APB是最简单的AMBA总…

产品手册应该如何组织内容,以便用户能够快速找到所需信息?

产品手册应该如何组织内容&#xff0c;以便用户能够快速找到所需信息&#xff1f;这是一个关乎用户体验和产品文档效力的重要问题。当用户需要了解产品的功能、操作指南或故障排除时&#xff0c;他们希望能够轻松地找到准确、清晰的信息&#xff0c;而不是在冗长的手册中迷失方…

Selenium处理Cookie

01、cookie介绍 HTTP协议是无状态的协议。一旦数据交换完毕&#xff0c;客户端与服务器端的连接就会关闭&#xff0c;再次交换数据需要建立新的连接&#xff0c;这就意味着服务器无法从连接上跟踪会话。也就是说即使第一次和服务器连接后并且登录成功后&#xff0c;第二次请求…

uniapp 离线打包 google 登录

官方文档&#xff1a; Oauth 模块 | uni小程序SDK 其中有 clientid 和反向url clientid 是 xxxx.apps.googleusercontent.com 反向url 是 com.googleusercontent.apps.xxx

【Android】android studio 怎么下载NDK

序言 新版的android studio在【Project Structure】里面的NDK路径是灰色的&#xff0c;无法点击&#xff0c;导致找不到ndk路径&#xff0c;也无法添加ndk。 下载方法 去这里找&#xff0c;一定要点这个按钮才能出现ndk。 下载之后&#xff0c;要在这个文件里面添加ndk路径

HT5010 音频转换器工作原理

HT5010是一款低成B的立体声DA转换器&#xff0c;内部集成了内插滤波器、DA转换器和输出模拟滤波等电路。其可支持多种音频数字输入格式&#xff0c;支持24-bit字节。 该HT5010 基于一个多比特位的Δ-Σ调制器&#xff0c;将数字信号转化成两个声道的模拟信号并经过模拟滤波器滤…

Hadoop环境搭建

1 Hadoop集群环境搭建概述 所谓集群&#xff0c;就是一组通过网络互联的计算机&#xff0c;集群中的每一台计算机称作一个节点&#xff0c;Hadoop集群搭建就是在这个物理集群之上安装部署Hadoop相关的软件&#xff0c;然后对外提供大数据存储和分析等相关服务。 一个前提&…

设置IDEA快捷生成方法头,类头注释

1.File->settings->editor->live templates进入Live Template界面进行设置&#xff1a; 下一步&#xff1a; 下一步&#xff1a; /*** Title: $title$* author: sunyanzeng* date: $datatime$*/在需要添加文件头的地方打出“aa”&#xff0c;回车&#xff0c;会自…

postgresql 触发器如何生成递增序列号,从1开始,并且每天重置

大家好&#xff0c;我是三叔&#xff0c;许久不见&#xff0c;这期给大家介绍一下笔者在开发中遇到的业务处理&#xff1a;pgsql 创建触发器生成每日递增序列&#xff0c;并且第二天重置&#xff0c;根据不同的用户进行不同的控制。 1.创建生成递增序列的 table 表 -- 创建us…

MySQL8.0.26-unbuntu版安装

MySQL8.0.26-ubuntu版安装 在这里会有一个坑&#xff0c;就是我在安装的时候,是按照另外一种版本的安装&#xff0c;报错没有rpm这个包&#xff0c;然后我就去下载&#xff0c;然后就报错 E: 无法定位软件包 &#xff0c;害的我找了好久的资料&#xff0c;一直没有解决&#x…