java 工作杂记 @上源码

1.AOP参数获取

Object[] params = joinPoint.getArgs();
MethodSignature methodSignature = (MethodSignature) joinPoint.getSignature();
Map map = new HashMap<>();
for (int i = 0 ; i < parameterNames.length; i++){
    map.put(parameterNames[i], params[i]);
}

2.Springboot 单测

@RunWith(SpringRunner.class)
@ActiveProfiles("dev")
@SpringBootTest

3.Maven 打包命令

-Dspring.profiles.active=dev

mvn clean install -DskipTests=true

4.mybatis开启驼峰自动转换模式

mybatis.configuration.map-underscore-to-camel-case=true

5.前后端时间转换 

@JsonFormat( pattern="yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")

spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
spring.jackson.time-zone=GMT+8

5.Long String 前后端转换

import com.fasterxml.jackson.databind.annotation.JsonDeserialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize;

@JsonSerialize(using = LongJsonSerializer.class)

@JsonDeserialize(using = LongJsonDeserializer.class)

用户处理前端Long类型数据丢失精度问题,将后端long类型转换成String类型,将前端的String类型转换成long类型

6.fastjson gson fastjson

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.gson.Gson;
import java.util.Map;
public class JsonTest {
    private static ObjectMapper objectMapper = new ObjectMapper();
    private static Gson gson = new Gson();
    private static JSONObject jsonObject = new JSONObject();
    public static void main(String[] args) throws Exception {
        Demo demo = new Demo();
        String jsonStr = gson.toJson(demo);
        jsonStr = objectMapper.writeValueAsString(demo);
        jsonStr = jsonObject.toJSONString(demo);
        String json = "{\"cmd\":\"1\",\"sss\":\"dd\"}";
        Map map = gson.fromJson(json, Map.class);
        map = objectMapper.readValue(json, Map.class);
        map = jsonObject.parseObject(json, Map.class);
        JSONObject jsonObject = JSON.parseObject(json);
    }
}

6.其他

MapUtils.getString(hashMap, "errcode")

Collections.EMPTY_LIST

@浅见 @如有疏漏请帮忙补充完善 @开发一家人  0000015   持续更新  感兴趣可以 点赞 收藏 评论 大家一起交流呀

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值