How to resolve the conflict between FastJSON and Jersey
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.