@JsonProperty失效
时间: 2023-10-02 21:14:09 浏览: 65
@JsonProperty失效的原因可能是因为项目同时引用了fastJson,而在项目中使用了FastJson做json序列化。FastJson在序列化时不会识别@JsonProperty注解。解决这个问题的方法有两种:
1. 在启动类上添加@EnableWebMvc注解,这样可以确保使用Jackson进行json序列化而不使用FastJson。
2. 如果不需要使用FastJson,可以直接在项目中移除对FastJson的引用。
在这种情况下,可以尝试在项目中使用@EnableWebMvc注解解决@JsonProperty失效的问题。将该注解添加到启动类上,例如在SpringBoot的启动类上添加@EnableWebMvc注解。这样做可以确保使用Jackson进行json序列化而不使用FastJson。如果项目中需要使用FastJson,那么可能需要重新考虑如何处理@JsonProperty注解失效的问题。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* [@JsonProperty 失效问题的排查](https://blog.csdn.net/m0_37948170/article/details/85327093)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
- *3* [详解关于使用媒体查询@meda失效原因的总结](https://download.csdn.net/download/weixin_38712416/12879385)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]