Closed canbingzt closed 1 year ago
系统内目前有3套JSON组件
JSONUtil
目前我发现的问题有以下几点
SecurityUtils
getCurrentUserId()
getCurrentUserDataScope()
LogServiceImpl
getParameter(Method method, Object[] args)
@JsonManagedReference
@JsonBackReference
@JsonIgnore
@JSONField(serialize = false)
ConfigurerAdapter
ResponseEntity<?>
InputStreamResource
HttpServletResponse
@EnableWebMvc
ObjectMapper
spring.jackson.*
想法很好,个人非常不接受一个项目很多种json操作包。除非是依赖包的功能无法满足
系统内目前有3套JSON组件
JSONUtil
目前我发现的问题有以下几点
SecurityUtils
里的getCurrentUserId()
和getCurrentUserDataScope()
,这里没有什么问题,用什么都是可以的LogServiceImpl
的getParameter(Method method, Object[] args)
方法,使用了Hutool的JSON组件,这里如果序列化的参数出现了循环引用,则没有办法去避免异常的产生。如果使用Jackson,则可以使用@JsonManagedReference
和@JsonBackReference
,或者使用@JsonIgnore
来避免异常。如果使用fastjson,同样可以使用@JSONField(serialize = false)
。ConfigurerAdapter
类里,配置了fastjson来格式化时间的converter,此处配置会导致其他默认的converter失效;比如,会导致无法使用ResponseEntity<?>
来返回InputStreamResource
来提供文件下载功能;所以目前文件下载都是用HttpServletResponse
来实现的。此处我建议取消添加额外的converter,使用SpringBoot自带的jackson即可,关于时间的格式化完全可以交给前端来做。@EnableWebMvc
会导致产生一个独立的ObjectMapper
,不受任何spring.jackson.*
配置设置影响。