jackson转范型
发表于|更新于
|浏览量:
不下决心培养思考习惯的人,便失去了生活中的最大乐趣。——爱迪生
代码很简单
1 | mapper.readValue(json, mapper.constructType(type)) |
这里主要是来源com.alibaba.nacos.common.utils.JacksonUtils#toObj(java.lang.String, java.lang.reflect.Type)
主要是这个mapper.constructType(type)
还可以
1 | TypeFactory typeFactory = mapper.getTypeFactory(); |
相关推荐
2022-12-12
开源ocr库tesseract
强者容易坚强,正如弱者容易软弱。——爱默生 分享一个开源的OCR库 文档链接:https://tesseract-ocr.github.io/ 源码地址:https://github.com/tesseract-ocr/tesseract 其包含了多种编程语言
2021-10-23
ThreadLocal子线程共享
世人缺乏的是毅力,而非气力。——雨果 昨天聊了ThreadLocal可以用作单个线程中变量共享 其底层实现其实就是个Map,用线程作为key,不信可以看这部分源码: 123456789101112131415161718192021/** * Returns the value in the current thread's copy of this * thread-local variable. If the variable has no value for the * current thread, it is first initialized to the value returned * by an invocation of the {@link #initialValue} method. * * @return the current thread's value of this thread-local */public T get() { Thread t = Thread.currentThr...
2020-06-07
HashMap
HashMap是由数组和链表组合构成的数据结构。 大概如下,数组里面每个地方都存了Key-Value这样的实例,在Java1.7叫Entry,在Java1.8中叫Node。 因为它本身所有位置都为null,在put插入的时候会根据key的hash去计算一个index值。 就比如我put(”rubenwei”,666),我插入了为”rubenwei”的元素,这个时候我们会通过哈希函数计算出插入的位置,如果计算出来index是2,那就放在第三个位置 但我们知道数组长度是有限的,在有限的长度里面我们使用哈希,哈希本身就存在概率性,就是”rubenwei”和“ruben”我们都去hash有一定的概率计算出来的hashcode是重复的,这时候如果put“ruben”就会在当前entry节点下形成一个链表用于存放hashcode一样的这些元素 每一个节点都会保存自身的hash、key、value以及(next)下个节点 java8之前采用头插法,原有的值顺推到链表中去,新来的值变成链表表头,是因为代码作者认为新来的值会被查找的可能性大一点,为了提升查找的效率设计的 java8之后改用尾插法,...
2020-08-13
fastjson基本使用
alibaba的fastjson真香啊 首先是依赖 123456<!-- https://mvnrepository.com/artifact/com.alibaba/fastjson --><dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.73</version></dependency> 这里列举点简单的应用 首先是对象转JSON 1234567Map<String, Object> map = new HashMap<>(1 << 3);map.put("data", "操作成功!");map.put("code", 200);map.put("success", true);map.put("...
2023-05-08
为streampark新增用户资源转移功能
凡事一俭,则谋生易足;谋生易足,则求人无争,亦于人无求。——钱泳 相关的pr:https://github.com/apache/incubator-streampark/pull/2734 对应的描述: What changes were proposed in this pull requestIssue Number: close #2712 Brief change log Requirement: The administrator cancels the user deletion function and replaces it with disabling users. Detailed logic: The administrator cancels the user deletion function. When the user account is disabled, it cannot own resources (application and project ownership) Add resource transfer func...
2022-10-28
r2dbc指定时区问题
政治能把一个人突然变老——巴尔扎克 今天看见这个警告 我的配置项如下: 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647import cn.hutool.core.util.StrUtil;import com.alibaba.druid.util.JdbcUtils;import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DataSourceProperty;import com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceProperties;import io.r2dbc.spi.ConnectionFactories;import io.r2dbc.spi.ConnectionFactory;import io.r2dbc.spi.ConnectionFactoryOption...

阿超
我的名字叫阿超 年龄25岁 家在北京市 职业是软件开发 每天最晚也会在八点前回家 不抽烟 酒浅尝辄止 晚上十二点上床 保证睡足八个小时 睡前写一篇博客 再做二十分钟俯卧撑暖身 然后再睡觉 基本能熟睡到天亮 像婴儿一样不留下任何疲劳和压力 就这样迎来第二天的早晨 健康检查结果也显示我很正常 我想说明我是一个不论何时都追求内心平稳的人 不拘泥于胜负 不纠结于烦恼 不树立使我夜不能寐的敌人 这就是我在这社会的生活态度
Follow Me公告
This is my Blog