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

企业级-实现Redis封装层

作者:fyupeng
技术专栏:☞ https://github.com/fyupeng
项目地址:☞ https://github.com/fyupeng/distributed-blog-system-api


留给读者

封装 Redis 客户端Dao层、分布式锁等。

一、介绍

二、代码

DataInitialLoadRunner.java

/*** @ClassName: DataInitialLoadRunner* @Description: 程序启动时初始化加载操作**/
@Component
@Order(value = 1)
public class DataInitialLoadRunner implements CommandLineRunner {protected final static Logger logger = LoggerFactory.getLogger(DataInitialLoadRunner.class);@Autowiredprivate ApplicationContext context;/*** 执行程序启动时初始化加载操作* * @param args* @throws Exception* @see CommandLineRunner#run(String[])*/@Overridepublic void run(String... args) throws Exception {logger.info(">>>>>>>>>common系统初始化数据操作开始<<<<<<<<<<");// 开始时间long begin = System.currentTimeMillis();//获取当前启动参数CoreConstants.PROFILE_NAME = context.getEnvironment().getActiveProfiles()[0];logger.info(">>>>>>>>>当前启动参数:"+CoreConstants.PROFILE_NAME);// 加载redis连接池	RedisManager.init();// 加载获取gwssi-core.properties配置文件ResourceBundle torchBundle = ResourceBundle.getBundle("gwssi-core");//电子文书文件参数初始化设置CoreConstants.DOC_APPLY_DATASOURCE_KEY=torchBundle.getString("doc.apply.datasource.key"); //申请端电子文书数据源keyCoreConstants.DOC_REDIS_DBINDEX = Integer.parseInt(torchBundle.getString("doc.redis.index")); // redis库IDCoreConstants.DOC_CONFIG_PATH = torchBundle.getString("doc.config.path"); // 电子文书xml文件路径CoreConstants.DOC_BASE_URL_PATH = torchBundle.getString("doc.base.url.path");//CoreConstants.FILE_IDENTITY_PATH= torchBundle.getString("file.identity.path"); //身份认证文件上传路径String initLoad = torchBundle.getString("init.load");// 检查程序每次启动时是否都要再加载一遍XML文件放入缓存中if (StringUtil.isNotBlank(initLoad.trim()) && "true".equals(initLoad.trim())) {logger.info("文书配置加载完成");}long end = System.currentTimeMillis(); // 结束时间logger.info(">>>>>>>>>系统初始化数据操作结束:" + (end - begin) + "ms<<<<<<<<<<");}}

RedisManager.java

/*** redis连接池获取数据源连接**/
public class RedisManager {private static Pool<Jedis> pool;protected final static Logger logger = LoggerFactory.getLogger(RedisManager.class);/*** 初始化redis连接池连接*/public static void init() throws Exception {// 加载读取application.properties文件String profile = CoreConstants.PROFILE_NAME;String profilename = "application";if (StringUtils.isNotBlank(profile)) {profilename += ("-" + profile);}logger.info("profilename=" + profilename);ResourceBundle torchBundle = ResourceBundle.getBundle(profilename);//>>>>>>>>初始化Redis连接池<<<<<<<<if (torchBundle == null) {throw new RuntimeException("没有找到redis配置文件");}String host = torchBundle.getString("spring.redis.host"); // redis IP地址int port = Integer.valueOf(torchBundle.getString("spring.redis.port")); // 端口号String password = "";if (torchBundle.containsKey("spring.redis.password")) {password = torchBundle.getString("spring.redis.password"); // 密码}logger.info("redis.host=" + host + "----redis.port=" + port);// 创建jedis池配置实例JedisPoolConfig jedisPoolConfig = new JedisPoolConfig();// 设置池配置项值// 最大连接数int poolMaxTotal = Integer.valueOf(torchBundle.getString("spring.redis.maxActive").trim());jedisPoolConfig.setMaxTotal(poolMaxTotal);// 最大空闲连接数int poolMaxIdle = Integer.valueOf(torchBundle.getString("spring.redis.maxIdle").trim());int poolMinIdle = Integer.valueOf(torchBundle.getString("spring.redis.MinIdle").trim());jedisPoolConfig.setMaxIdle(poolMaxIdle);jedisPoolConfig.setMinIdle(poolMinIdle);jedisPoolConfig.setMaxTotal(200);// 获取连接时的最大等待毫秒数,小于零:阻塞不确定的时间,默认-1long poolMaxWaitMillis = Long.valueOf(torchBundle.getString("spring.redis.maxWaitMillis").trim());jedisPoolConfig.setMaxWaitMillis(poolMaxWaitMillis);//拿到连接的时候是否进行校验操作jedisPoolConfig.setTestOnBorrow(true);//连接归还池进行校验jedisPoolConfig.setTestOnReturn(true);
//表示idle object evitor两次扫描之间要sleep的毫秒数jedisPoolConfig.setTimeBetweenEvictionRunsMillis(30000);
//表示idle object evitor每次扫描的最多的对象数jedisPoolConfig.setNumTestsPerEvictionRun(10);
//表示一个对象至少停留在idle状态的最短时间,然后才能被idle object evitor扫描并驱逐;这一项只有在timeBetweenEvictionRunsMillis大于0时才有意义jedisPoolConfig.setMinEvictableIdleTimeMillis(60000);// 添加连接池if (StringUtils.isNotBlank(password)) {int timeOut = Integer.valueOf(torchBundle.getString("spring.redis.timeOut")); // 超时时间pool = new JedisPool(jedisPoolConfig, host, port, timeOut, password);} else {pool = new JedisPool(jedisPoolConfig, host, port);}logger.info("redis 初始化完成");}/*** 获取Jedis对象** @return*/public static Jedis getResource() {Jedis jedis = pool.getResource();return jedis;}/*** 获取Jedis对象** @param db 数据库序号* @return*/public static Jedis getResource(int db) {//索引0 =线程//索引1 =这个//索引2 =直接呼叫者,可以是自己。//索引3 ... n =相互调用以获得索引2及以下的类和方法。/*StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace();for (int i = 0; i < stackTrace.length; i++){StackTraceElement s = stackTrace[i];System.out.format(" ClassName:%d\t%s\n", i, s.getClassName());System.out.format("MethodName:%d\t%s\n", i, s.getMethodName());System.out.format("  FileName:%d\t%s\n", i, s.getFileName());System.out.format("LineNumber:%d\t%s\n\n", i, s.getLineNumber());}*/Jedis jedis = pool.getResource();jedis.select(db);return jedis;}/*** 销毁** @throws Exception*/public static void destroy() throws Exception {pool.destroy();}
}

Redis工具类

/*** redis工具类**/
public class RedisUtils {protected final static Logger logger = LoggerFactory.getLogger(RedisUtils.class);private static final long sleepTime = 100L;/*** 根据dbindex删除缓存** @param dbIndex*/public static void flushDB(int dbIndex) {Jedis jedis = null;try {jedis = RedisManager.getResource(dbIndex);jedis.flushDB();} catch (Exception e) {logger.error("redis-flushDB异常", e);} finally {if (jedis != null) {jedis.close();}}}/*** set集合** @param key* @param value*/public static void set(String key, Object value, int dbIndex) {Jedis jedis = null;try {jedis = RedisManager.getResource(dbIndex);if (value instanceof String) {jedis.set(key, String.valueOf(value));} else {jedis.set(key.getBytes(), serialize(value));}} catch (Exception e) {logger.error("redis-set异常", e);} finally {if (jedis != null) {jedis.close();}}}/*** set集合, 有过期时间** @param key* @param value* @param second*/public static void setex(String key, int second, Object value, int dbIndex) {Jedis jedis = null;try {jedis = RedisManager.getResource(dbIndex);if (value instanceof String) {jedis.setex(key, second, String.valueOf(value));} else {jedis.setex(key.getBytes(), second, serialize(value));}} catch (Exception e) {logger.error("redis-set异常", e);} finally {if (jedis != null) {jedis.close();}}}/*** @param 参数* @return void    返回类型* @throws* @Title: expire* @Description: 设置时间*/public static void expire(String key, int secends, int dbIndex) {Jedis jedis = null;try {jedis = RedisManager.getResource(dbIndex);jedis.expire(key.getBytes(), secends);} catch (Exception e) {logger.error("redis-expire异常", e);} finally {if (jedis != null) {jedis.close();}}}/*** 从redis缓存中获取key的值*/public static String get(String key, int dbIndex) {Jedis jedis = null;try {jedis = RedisManager.getResource(dbIndex);return jedis.get(key);} catch (Exception e) {logger.error("redis-get异常", e);} finally {if (jedis != null) {jedis.close();}}return null;}/*** @param 参数* @return Object    返回类型* @throws* @Title: get* @Description: key查询返回Object对象*/public static Object get(byte[] key, int dbIndex) {Jedis jedis = null;try {jedis = RedisManager.getResource(dbIndex);logger.info("redis取值:" + key.toString());return unserialize(jedis.get(key));} catch (Exception e) {logger.error("redis-get异常", e);} finally {if (jedis != null) {jedis.close();}}return null;}/*** 根据key删除缓存** @param key*/public static void delete(String[] key, int dbIndex) {Jedis jedis = null;try {jedis = RedisManager.getResource(dbIndex);logger.info("redis删除:" + key);jedis.del(key);} catch (Exception e) {logger.error("redis-delete异常", e);} finally {if (jedis != null) {jedis.close();}}}/*** 设置 map** @param <T>* @param key* @param value*/public static <T> void setMap(String key, Map<String, T> map, int dbIndex) {Jedis jedis = null;try {jedis = RedisManager.getResource(dbIndex);jedis.set(key.getBytes(), serialize(map));} catch (Exception e) {logger.error("redis-setMap异常", e);} finally {if (jedis != null) {jedis.close();}}}/*** 获取list** @param <T>* @param key* @return list*/public static <T> Map<String, T> getMap(String key, int dbIndex) {Jedis jedis = null;try {jedis = RedisManager.getResource(dbIndex);if (jedis == null || !jedis.exists(key.getBytes())) {return null;}byte[] in = jedis.get(key.getBytes());@SuppressWarnings("unchecked")Map<String, T> map = (Map<String, T>) unserialize(in);return map;} catch (Exception e) {logger.error("redis-getMap异常", e);} finally {if (jedis != null) {jedis.close();}}return null;}/*** 设置object** @param <T>* @param key* @param object*/public static <T> void setObject(String key, Object object, int dbIndex) {Jedis jedis = null;try {jedis = RedisManager.getResource(dbIndex);jedis.set(key.getBytes(), serialize(object));} catch (Exception e) {logger.error("redis-setObject异常", e);} finally {if (jedis != null) {jedis.close();}}}/*** 获取object** @param <T>* @param key* @return list*/public static <T> T getObject(String key, int dbIndex) {Jedis jedis = null;Object object = null;try {jedis = RedisManager.getResource(dbIndex);if (jedis == null || !jedis.exists(key.getBytes())) {return null;}byte[] in = jedis.get(key.getBytes());object = unserialize(in);} catch (Exception e) {logger.error("redis-getObject异常", e);} finally {if (jedis != null) {jedis.close();}}return object==null?null:(T)object;}/*** 设置 String** @param key* @param value*/public static void setString(String key, String value, int dbIndex) {Jedis jedis = null;try {jedis = RedisManager.getResource(dbIndex);// value = StringUtil.isNullOrEmpty(value) ? "" : value;jedis.set(key, value);} catch (Exception e) {logger.error("redis-setString异常", e);} finally {if (jedis != null) {jedis.close();}}}/*** 设置 过期时间** @param key* @param seconds 以秒为单位* @param value*/public static void setString(String key, int seconds, String value, int dbIndex) {Jedis jedis = null;try {jedis = RedisManager.getResource(dbIndex);// value = StringUtil.isNullOrEmpty(value) ? "" : value;jedis.setex(key, seconds, value);} catch (Exception e) {logger.error("redis-setString异常", e);} finally {if (jedis != null) {jedis.close();}}}/*** 获取String值** @param key* @return value*/public static String getString(String key, int dbIndex) {Jedis jedis = null;try {jedis = RedisManager.getResource(dbIndex);if (jedis == null || !jedis.exists(key)) {return null;}return jedis.get(key);} catch (Exception e) {logger.error("redis-getString异常", e);} finally {if (jedis != null) {jedis.close();}}return null;}/*** 设置 list** @param <T>* @param key* @param list*/public static <T> void setList(String key, List<T> list, int dbIndex) {Jedis jedis = null;try {jedis = RedisManager.getResource(dbIndex);jedis.set(key.getBytes(), serialize(list));} catch (Exception e) {logger.error("redis-setList异常", e);} finally {if (jedis != null) {jedis.close();}}}/*** 获取list** @param <T>* @param key* @return list*/@SuppressWarnings("unchecked")public static <T> List<T> getList(String key, int dbIndex) {Jedis jedis = null;try {jedis = RedisManager.getResource(dbIndex);if (jedis == null || !jedis.exists(key.getBytes())) {return null;}byte[] in = jedis.get(key.getBytes());List<T> list = (List<T>) unserialize(in);return list;} catch (Exception e) {logger.error("redis-getList异常", e);} finally {if (jedis != null) {jedis.close();}}return null;}public static byte[] getbyte(String key, int secends, int dbIndex) {Jedis jedis = null;try {jedis = RedisManager.getResource(dbIndex);if (null == jedis.get(key.getBytes())) {return null;} else {// 更新过期时间jedis.expire(key, secends);// 1小时}return jedis.get(key.getBytes());} catch (Exception e) {logger.error("session取Redis出现错误", e);return null;} finally {jedis.close();}}/** 序列化对象*/public static byte[] serialize(Object value) {if (value == null) {throw new NullPointerException("Can't serialize null");}byte[] rv = null;ByteArrayOutputStream bos = null;ObjectOutputStream os = null;try {bos = new ByteArrayOutputStream();os = new ObjectOutputStream(bos);os.writeObject(value);rv = bos.toByteArray();} catch (IOException e) {logger.error("redis-serialize异常", e);throw new IllegalArgumentException("Non-serializable object", e);} finally {try {if (os != null)os.close();if (bos != null)bos.close();} catch (Exception e2) {e2.printStackTrace();}}return rv;}/*** 反序列化对象** @return Object*/public static Object unserialize(byte[] in) {Object rv = null;ByteArrayInputStream bis = null;ObjectInputStream is = null;try {if (in != null) {bis = new ByteArrayInputStream(in);is = new ObjectInputStream(bis);rv = is.readObject();}} catch (Exception e) {logger.error("redis-unserialize异常", e);} finally {try {if (is != null)is.close();if (bis != null)bis.close();} catch (Exception e2) {e2.printStackTrace();}}return rv;}public static Long incr(String key, int dbIndex) {Jedis jedis = null;try {jedis = RedisManager.getResource(dbIndex);if (jedis == null) {return null;}return jedis.incr(key);} catch (Exception e) {logger.error("redis-getString异常", e);} finally {if (jedis != null) {jedis.close();}}return null;}/*** Jedis执行Lua脚本,获取结果** @param lua     Lua字符串* @param keys    keys* @param args    其他Lua需要参数* @param dbIndex 索引* @return*/public static Object evalLua(String lua, List<String> keys, List<String> args, int dbIndex) {Jedis jedis = null;try {jedis = RedisManager.getResource(dbIndex);if (jedis == null) {return null;}return jedis.eval(lua, keys, args);} catch (Exception e) {logger.error("redis-执行Lua异常", e);} finally {if (jedis != null) {jedis.close();}}return null;}/*** 自定义获取锁的超时时间** @param key* @param timeout* @param waitTime* @param timeUnit* @return* @throws InterruptedException*/public static boolean tryLock(String key, int timeout, long waitTime, TimeUnit timeUnit) throws InterruptedException {try (Jedis jedis = RedisManager.getResource(LOCK_DB_INDEX)) {long timeoutSeconds = timeUnit.toSeconds(timeout);long waitTimeMicroSeconds = timeUnit.toMicros(waitTime);while (waitTimeMicroSeconds >= 0) {String result = jedis.set(key, "1", "nx", "ex", timeoutSeconds);if ("OK".equals(result)) {return true;}waitTimeMicroSeconds -= sleepTime;Thread.sleep(sleepTime);}} catch (Exception e) {logger.error("redis-setString异常", e);}return false;}/*** 使用Lua脚本进行解锁操纵,解锁的时候验证value值** @param key* @return*/public static void unlock(String key) {try (Jedis jedis = RedisManager.getResource(LOCK_DB_INDEX)) {String luaScript = "if redis.call('get',KEYS[1]) == ARGV[1] then " +"return redis.call('del',KEYS[1]) else return 0 end";jedis.eval(luaScript, Collections.singletonList(key), Collections.singletonList("1")).equals(1L);} catch (Exception e) {logger.error("redis-setString异常", e);}}}

三、总结

简洁

相关文章:

企业级-实现Redis封装层

作者&#xff1a;fyupeng 技术专栏&#xff1a;☞ https://github.com/fyupeng 项目地址&#xff1a;☞ https://github.com/fyupeng/distributed-blog-system-api 留给读者 封装 Redis 客户端Dao层、分布式锁等。 一、介绍 二、代码 DataInitialLoadRunner.java /*** Clas…...

SpringBoot使用ApplicationContext.getBean启动报空指针处理记录

问题&#xff1a;项目启动报空指针 定位&#xff1a;新增filter中init方法使用getbean控制 解决&#xff1a;在新增filter上加注解 DependsOn({"applicationContextUtils"}) Component DependsOn({"applicationContextUtils"})//此处解决空指针问题 pu…...

MongoDB Shell 基本命令(三)聚合管道

管道含义 类似Linux中的管道&#xff0c;前一个命令的输出作为后一个命令的输入。 显示网络连接、路由表和网络接口统计信息 netstat -ano -netstat:network statistics 网络统计 -a:显示所有连接和监听端口&#xff0c;包括所有活动的TCP和UDP连接。 -n:以数字形式显示地址…...

Go语言的内置容器

文章目录 一、数组数组的定义数组声明数组特点数组元素修改 二、切片切片声明基于数组创建切片使用make()函数构造切片使用append()为切片动态添加元素\使用copy()复制新的切片数组与切片相互转换 三、Map映射Map定义使用make()函数创建map用切片作为map的值使用delete()函数删…...

HCIP考试怎样预约?随时可以考试吗?

HCIP&#xff08;华为认证互联网协议专家&#xff09;的考试并不是随时都能参加的&#xff0c;考生需要避开法定节假日来预约考试。具体的考试时间会根据所选的认证方向和考试中心有所变化。考生可以通过华为人才在线平台或者直接联系Pearson VUE来安排考试时间。 HCIP认证考试…...

香港航空 阿里滑块 acw_sc__v3 分析

声明: 本文章中所有内容仅供学习交流使用&#xff0c;不用于其他任何目的&#xff0c;抓包内容、敏感网址、数据接口等均已做脱敏处理&#xff0c;严禁用于商业用途和非法用途&#xff0c;否则由此产生的一切后果均与作者无关&#xff01; 有相关问题请第一时间头像私信联系我删…...

JS传统函数中常见的 this 绑定问题

在 JavaScript 中&#xff0c;传统函数的 this 绑定规则依赖于函数的调用方式&#xff0c;这常常导致一些意外的行为和常见的 this 绑定问题。以下是一些典型的 this 绑定问题及其解决方案。 1. 作为对象方法调用时的 this 丢失 当一个对象的方法被赋值给一个变量或作为回调函…...

跨域问题以及使用vscode的LiveServer插件跨域访问

目录 现象跨域问题的定义&#xff08;文心一言&#xff09;解决办法同源部署后端代理VS Code LiveServer 现象 以下前端代码部署后&#xff0c;在网页访问时报错&#xff1a;No ‘Access-Control-Allow-Origin’ header is present on the requested resource. $.ajax({url:…...

现代Web开发:WebSocket 实时通信详解

&#x1f493; 博客主页&#xff1a;瑕疵的CSDN主页 &#x1f4dd; Gitee主页&#xff1a;瑕疵的gitee主页 ⏩ 文章专栏&#xff1a;《热点资讯》 现代Web开发&#xff1a;WebSocket 实时通信详解 现代Web开发&#xff1a;WebSocket 实时通信详解 现代Web开发&#xff1a;WebS…...

《深度学习》——深度学习基础知识(全连接神经网络)

文章目录 1.神经网络简介2.什么是神经网络3.神经元是如何工作的3.1激活函数3.2参数的初始化3.2.1随机初始化3.2.2标准初始化3.2.3Xavier初始化&#xff08;tf.keras中默认使用的&#xff09;3.2.4He初始化 4.神经网络的搭建4.1通过Sequential构建神经网络4.2通过Functional API…...

nginx 部署2个相同的vue

起因&#xff1a; 最近遇到一个问题&#xff0c;在前端用nginx 部署 vue&#xff0c; 发现如果前端有改动&#xff0c;如果不适用热更新&#xff0c;而是直接复制项目过去&#xff0c;会404 因此想到用nginx 负载两套相同vue项目&#xff0c;然后一个个复制vue项目就可以了。…...

利用Java easyExcel库实现高效Excel数据处理

在Java应用程序中&#xff0c;处理Excel文件是一项常见任务&#xff0c;尤其是在需要读取、写入或分析大量数据时。easyExcel是一个基于Java的高性能Excel处理库&#xff0c;它提供了简洁的API和优化的性能&#xff0c;以简化Excel文件的处理。本文将指导您如何使用easyExcel库…...

Vulnhub靶场 Metasploitable: 1 练习(上)

目录 0x00 准备0x01 主机信息收集0x02 Samba服务&#xff08;CVE-2007-2447&#xff09;0x03 Distccd&#xff08;CVE-2004-2687&#xff09;0x04 Mysql弱口令0x05 Postgresql弱口令0x06 Telnet弱口令0x07 Tomcat 0x00 准备 下载链接&#xff1a;https://download.vulnhub.com/…...

《Python编程实训快速上手》第二天--列表与元组

一、列表 1、理解 列表是一个值&#xff0c;包含由多个值构成的序列 2、元素查找 1&#xff09;索引--取列表中的单个值 正数索引&#xff1a;同c语言中的数组 spam [[1,2,3,4],["cat","dog"]] print(spam[0][1]) #结果&#xff1a;2 负数索引&…...

jangow靶机

先改jangow的ip设置&#xff0c;无ip地址&#xff0c;重启jangow虚拟机时候快速按E这个键盘&#xff0c;进入到编辑模式&#xff0c;找到ro这个位置&#xff0c;写入ro rw signin init/bin/bash ​&#xff0c;ctrlx保存 下一步需要更改网卡名字为ens33&#xff0c;可以直接…...

使用UDP协议传输视频流!(分片、缓存)

背景 最近在开发工作中遇到需要两台本地设备之间进行视频流的传输的情况。但是团队一来没有这方面的专业人才&#xff0c;二来视频流的传续数据量很大&#xff0c;针对TCP和UDP的具体选择也不明确。 本文是在上诉背景之下进行的研究和开发工作。 目录 背景 UDP和TCP协议的…...

Pinia小菠萝(状态管理器)

Pinia 是一个专为 Vue 3 设计的状态管理库&#xff0c;它借鉴了 Vuex 的一些概念&#xff0c;但更加轻量灵活。下面将详细介绍如何使用 Pinia 状态管理库&#xff1a; 安装 Pinia 使用 npm&#xff1a;在项目目录下运行npm install pinia。使用 yarn&#xff1a;在项目目录下运…...

Python知识点:基于Python工具,如何使用Web3.py进行以太坊智能合约开发

开篇&#xff0c;先说一个好消息&#xff0c;截止到2025年1月1日前&#xff0c;翻到文末找到我&#xff0c;赠送定制版的开题报告和任务书&#xff0c;先到先得&#xff01;过期不候&#xff01; 基于Python工具Web3.py进行以太坊智能合约开发 简介 智能合约是区块链技术的核…...

【简信CRM-注册安全分析报告】

前言 由于网站注册入口容易被黑客攻击&#xff0c;存在如下安全问题&#xff1a; 暴力破解密码&#xff0c;造成用户信息泄露短信盗刷的安全问题&#xff0c;影响业务及导致用户投诉带来经济损失&#xff0c;尤其是后付费客户&#xff0c;风险巨大&#xff0c;造成亏损无底洞…...

ssm+vue694基于Java的药店药品信息管理系统的设计与实现

博主介绍&#xff1a;专注于Java&#xff08;springboot ssm 等开发框架&#xff09; vue .net php phython node.js uniapp 微信小程序 等诸多技术领域和毕业项目实战、企业信息化系统建设&#xff0c;从业十五余年开发设计教学工作 ☆☆☆ 精彩专栏推荐订阅☆☆☆☆☆不…...

深入浅出Asp.Net Core MVC应用开发系列-AspNetCore中的日志记录

ASP.NET Core 是一个跨平台的开源框架&#xff0c;用于在 Windows、macOS 或 Linux 上生成基于云的新式 Web 应用。 ASP.NET Core 中的日志记录 .NET 通过 ILogger API 支持高性能结构化日志记录&#xff0c;以帮助监视应用程序行为和诊断问题。 可以通过配置不同的记录提供程…...

树莓派超全系列教程文档--(61)树莓派摄像头高级使用方法

树莓派摄像头高级使用方法 配置通过调谐文件来调整相机行为 使用多个摄像头安装 libcam 和 rpicam-apps依赖关系开发包 文章来源&#xff1a; http://raspberry.dns8844.cn/documentation 原文网址 配置 大多数用例自动工作&#xff0c;无需更改相机配置。但是&#xff0c;一…...

C++:std::is_convertible

C++标志库中提供is_convertible,可以测试一种类型是否可以转换为另一只类型: template <class From, class To> struct is_convertible; 使用举例: #include <iostream> #include <string>using namespace std;struct A { }; struct B : A { };int main…...

React Native 导航系统实战(React Navigation)

导航系统实战&#xff08;React Navigation&#xff09; React Navigation 是 React Native 应用中最常用的导航库之一&#xff0c;它提供了多种导航模式&#xff0c;如堆栈导航&#xff08;Stack Navigator&#xff09;、标签导航&#xff08;Tab Navigator&#xff09;和抽屉…...

VB.net复制Ntag213卡写入UID

本示例使用的发卡器&#xff1a;https://item.taobao.com/item.htm?ftt&id615391857885 一、读取旧Ntag卡的UID和数据 Private Sub Button15_Click(sender As Object, e As EventArgs) Handles Button15.Click轻松读卡技术支持:网站:Dim i, j As IntegerDim cardidhex, …...

从WWDC看苹果产品发展的规律

WWDC 是苹果公司一年一度面向全球开发者的盛会&#xff0c;其主题演讲展现了苹果在产品设计、技术路线、用户体验和生态系统构建上的核心理念与演进脉络。我们借助 ChatGPT Deep Research 工具&#xff0c;对过去十年 WWDC 主题演讲内容进行了系统化分析&#xff0c;形成了这份…...

【2025年】解决Burpsuite抓不到https包的问题

环境&#xff1a;windows11 burpsuite:2025.5 在抓取https网站时&#xff0c;burpsuite抓取不到https数据包&#xff0c;只显示&#xff1a; 解决该问题只需如下三个步骤&#xff1a; 1、浏览器中访问 http://burp 2、下载 CA certificate 证书 3、在设置--隐私与安全--…...

2025 后端自学UNIAPP【项目实战:旅游项目】6、我的收藏页面

代码框架视图 1、先添加一个获取收藏景点的列表请求 【在文件my_api.js文件中添加】 // 引入公共的请求封装 import http from ./my_http.js// 登录接口&#xff08;适配服务端返回 Token&#xff09; export const login async (code, avatar) > {const res await http…...

今日科技热点速览

&#x1f525; 今日科技热点速览 &#x1f3ae; 任天堂Switch 2 正式发售 任天堂新一代游戏主机 Switch 2 今日正式上线发售&#xff0c;主打更强图形性能与沉浸式体验&#xff0c;支持多模态交互&#xff0c;受到全球玩家热捧 。 &#x1f916; 人工智能持续突破 DeepSeek-R1&…...

在QWebEngineView上实现鼠标、触摸等事件捕获的解决方案

这个问题我看其他博主也写了&#xff0c;要么要会员、要么写的乱七八糟。这里我整理一下&#xff0c;把问题说清楚并且给出代码&#xff0c;拿去用就行&#xff0c;照着葫芦画瓢。 问题 在继承QWebEngineView后&#xff0c;重写mousePressEvent或event函数无法捕获鼠标按下事…...