mercredi 18 février 2015

Conflic setter for property in jackson

I have a problem in my webservice controller, due to jackson's serialisation of a third party object.



java.lang.IllegalArgumentException: Conflicting setter definitions for property "X": ThirdPartyClass#setX(1 params) vs ThirdPartyClass#setX(1 params)



I've read that you can solve it thanks to MixIn annotation.


In my controller i'm giving a list, i'd like to know if there is a way to automatically define somewhere the use of the MixInAnnotation ?


If i had to do it for one object, i'd do something like that:



ObjectMapper mapper = new ObjectMapper();
mapper.getSerializationConfig().addMixInAnnotations(xxx);
return mapper.writeValueAsString(myObject);


Nevertheless, my controller is doing:



@RequestMapping(method = RequestMethod.GET)
public @ResponseBody List<MyObject> getMyObjects


and several times returning MyObject in other methods, and so i'd like to declare only one time the use of the MixInAnnotation for jackson serialisation ?


Thank you, RoD


Aucun commentaire:

Enregistrer un commentaire