更换默认序列化器
发表于|更新于
|浏览量:
一个人至少拥有一个梦想,有一个理由去坚强。——三毛
springboot默认使用jackson进行序列化
如果我们想使用fastJson
则可以注入一个HttpMessageConverters
1 | @Bean |
我们测试一下
给我们的bean中属性keywords加上注解@JSONField(name = "keyword")

我们传值使用keyword,发现成功接收


相关推荐
2023-12-26
docker运行seata
怀疑一切与信任一切是同样的错误,能得乎其中方为正道。——乔叟 https://hub.docker.com/r/seataio/seata-server 命令: 1docker run --name seata-server -p 8091:8091 -p 7091:7091 seataio/seata-server:latest 自定义配置文件: 123456docker run --name seata-server \ -p 8091:8091 \ -p 7091:7091 \ -e SEATA_CONFIG_NAME=file:/root/seata-config/registry \ -v /PATH/TO/CONFIG_FILE:/root/seata-config \ seataio/seata-server 指定ip 12345docker run --name seata-server \ -p 8091:8091 \ -p 7091:7091 \ ...
2022-10-25
jackson时区问题
万两黄金容易得,知心一个也难求——曹雪芹 今天发现日期数据返回后日期错乱 怀疑是时区问题,果然改了全局jackson序列化配置就好了 12ObjectMapper objectMapper = new ObjectMapper();objectMapper.setTimeZone(TimeZone.getTimeZone("GMT+8")); 完整代码: 12345678910111213141516171819202122232425262728293031323334353637383940/** * web配置类 * * @author <achao1441470436@gmail.com> * @since 2021/5/18 0018 14:52 */@Configuration@EnableWebMvcpublic class WebConfig implements WebMvcConfigurer { /** * @param converters 转换器 * @author <a...
2022-12-17
获取lambda代理
伯乐不可欺以马,君子不可欺以人——荀子 代码如下: 123MethodHandles.Lookup lookup = MethodHandles.lookup(); MethodHandle getR = lookup.findVirtual(B.class, "getR", MethodType.methodType(Object.class)); SerFunc<Object, B> lambda = MethodHandleProxies.asInterfaceInstance(SerFunc.class, getR); 此处的lambda代理对象同样可以执行lambda对应的方法
2020-12-03
@PostConstruct使用
在项目中我们可以使用@PostConstruct去初始化一些操作 例如 1234567891011121314151617181920212223242526package com.ruben;import com.ruben.dao.MpUserMapper;import org.junit.jupiter.api.Test;import org.springframework.boot.test.context.SpringBootTest;import javax.annotation.PostConstruct;import javax.annotation.Resource;@SpringBootTestclass SimpleSpringbootApplicationTests { private String name; @PostConstruct public void init() { name = "ruben"; } @Test void test(...
2024-03-16
mybatis的@MappedTypes
“Given enough eyeballs, all bugs are shallow.” — Linus’s Law, Eric S. Raymond 看到com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler的源码 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778/* * Copyright (c) 2011-2023, baomidou (jobob@qq.com). * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * ...
2023-10-14
srs的http api鉴权
怒后不可便食,食后不可发怒。——梁章钜 文档 https://ossrs.net/lts/zh-cn/docs/v5/doc/http-api#authentication 12345678910# conf/http.api.auth.confhttp_api { enabled on; listen 1985; auth { enabled on; username admin; password admin; }} 配置了之后如何访问? 12345678910111213141516171819fetch("http://localhost:1985/api/v1/clients/", { "headers": { 'Authorization': 'Basic ' + btoa(`admin` + ":" + `admin`), ...
