java - Custom JSON ObjectMapper : no matching editors or conversion strategy found -
i trying create custom objectmapper getting issues. want use tostring method of enum used during serialization:
xml configuration:
<bean id="resttemplatems" class="org.springframework.web.client.resttemplate"> <constructor-arg ref="httpclientfactory" /> <property name="messageconverters"> <list> <bean class="org.springframework.http.converter.json.mappingjacksonhttpmessageconverter"> <property name="supportedmediatypes"> <list> <value>somethio</value> </list> </property> <property name="objectmapper" ref="customobjectmapper"/> </bean> </list> </property> </bean> <bean id="customobjectmapper" class="com.mag.xxx.customjsonobjectmapper"/>
java:
import org.codehaus.jackson.map.objectmapper; import org.codehaus.jackson.map.serializationconfig; public class customjsonobjectmapper extends objectmapper { public customjsonobjectmapper() { super(); this.configure(serializationconfig.feature.write_enums_using_to_string, true); } }
error:
caused by: java.lang.illegalstateexception: cannot convert value of type [com.mag.xxx.customjsonobjectmapper] required type [org.codehaus.jackson.map.objectmapper] property 'objectmapper': no matching editors or conversion strategy found @ org.springframework.beans.typeconverterdelegate.convertifnecessary(typeconverterdelegate.java:241) @ org.springframework.beans.beanwrapperimpl.convertifnecessary(beanwrapperimpl.java:470)
Comments
Post a Comment