问题:jaskson反序列化超出最大长度
Caused by: com.fasterxml.jackson.core.exc.StreamConstraintsException: String length (5043456) exceeds the maximum length (5000000)
场景:前端传递过大base64
原因:
jaskon默认已经限制了最大长度
解决方案
修改spring配置jackson配置bean:
@BeanJackson2ObjectMapperBuilderCustomizer customStreamReadConstraints() {return (builder) -> builder.postConfigurer((objectMapper) -> objectMapper.getFactory().setStreamReadConstraints(StreamReadConstraints.builder().maxNestingDepth(2000).maxStringLength(Integer.MAX_VALUE).build()));}