json - How to overcome "Conflicting setter definitions for property "? -
i use com.fasterxml.jackson
, io.swagger
libraries. in rest endpoint use org.javamoney.moneta.money
type query. when deploying war following exception 1;
i have followed reference , wrote following code[2]; , registered @ @applicationpath. still getting same issue. guide helpful?
@applicationpath("/rest") public class restapplication extends application { @override public set<class<?>> getclasses() { hashset<class<?>> set = new hashset<class<?>>(); set.add(com.test.jsonmoneyprovider.class);
[2]
import javax.money.currencyunit; import javax.money.monetary; import javax.money.monetaryamountfactory; import javax.ws.rs.ext.provider; import javax.xml.bind.annotation.xmltransient; import com.fasterxml.jackson.annotation.jsonignore; import com.fasterxml.jackson.databind.objectmapper; import com.fasterxml.jackson.jaxrs.json.jacksonjsonprovider; @provider public class jsonmoneyprovider extends jacksonjsonprovider { public jsonmoneyprovider() { objectmapper mapper = new objectmapper(); mapper.addmixin(monetaryamountfactory.class, mixin.class); setmapper(mapper); } public static interface mixin { @jsonignore @xmltransient monetaryamountfactory setcurrency(currencyunit currency); @jsonignore @xmltransient default monetaryamountfactory setcurrency(string currencycode) { return setcurrency(monetary.getcurrency(currencycode)); } } }
caused by: java.lang.illegalargumentexception: conflicting setter definitions property "currency": javax.money.monetaryamountfactory#setcurrency(1 params) vs javax.money.monetaryamountfactory#setcurrency(1 params) @ com.fasterxml.jackson.databind.introspect.pojopropertybuilder.getsetter(pojopropertybuilder.java:293) @ io.swagger.jackson.modelresolver.resolve(modelresolver.java:246) @ io.swagger.jackson.modelresolver.resolve(modelresolver.java:127) @ io.swagger.converter.modelconvertercontextimpl.resolve(modelconvertercontextimpl.java:99) @ io.swagger.jackson.modelresolver.resolveproperty(modelresolver.java:106)
Comments
Post a Comment