Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to resolve the conflict between FastJSON and Jersey

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

In this issue, the editor will bring you about how to resolve the conflict between FastJSON and Jersey. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.

When testing hugegraph, the official default Example Code call fails, and Debug finds that the PropertyKey sent by HTTPClient does not have a field when serializing JSON.

Description: my project is in the actual project, there are a large number of dependencies can not be removed. After looking at the PropertyKey code, it is found that JSON is bound to the jackson implementation, and for the Builder pattern, FastJSON generation of JSON has always been unintelligent, and it is initially suspected that fastjson caused the conflict.

Public class PropertyKey extends SchemaElement {@ JsonProperty ("data_type") private DataType dataType; @ JsonProperty ("cardinality") private Cardinality cardinality; @ JsonProperty ("aggregate_type") private AggregateType aggregateType;}

Du Niang part of the data, it turned out that fastjson in 1.2.36, add the implementation of JerseyAutoDiscoverable, when the jersey starts, it will automatically load FastJsonProvider. Downgrade fastjson to 1.2.35, no problem. Personally a little paranoid, jersey and fastjson do not want to downgrade. Look at the FastJsonAutoDiscoverable code and find that there is an autoDiscover switch:

Public volatile static boolean autoDiscover = true;@Overridepublic void configure (final FeatureContext context) {final Configuration config = context.getConfiguration (); if (! config.isRegistered (FastJsonFeature.class) & & autoDiscover) {context.register (FastJsonFeature.class);}}

Therefore, if you add a static code field to the project startup class and set autoDiscover to false, the problem will be solved.

Static {FastJsonAutoDiscoverable.autoDiscover = false;} above is how to resolve the FastJSON and Jersey conflict resolution shared by the editor. If you happen to have similar doubts, please refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report