Skip to content

Instantly share code, notes, and snippets.

@knalli
Created February 5, 2014 15:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save knalli/8825643 to your computer and use it in GitHub Desktop.
Save knalli/8825643 to your computer and use it in GitHub Desktop.
Spring Integration migration from 2.x to 3.x: Change Jackson1 to Jackson2, incl. Joda support
<beans>
<!--
Both json-to-object and object-tojson transformer needs the constructor
argument "object-mapper" which uses the custom mapper defined in IntegrationConfig
-->
<int:chain input-channel="requestChannelJson" output-channel="requestChannel">
<int:json-to-object-transformer object-mapper="jsonObjectMapper" type="your.package.to.response.Type"/>
</int:chain>
<int:chain input-channel="replyChannel" output-channel="replyChannelJson">
<int:object-to-json-transformer object-mapper="jsonObjectMapper"/>
</int:chain>
</beans>
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.joda.JodaModule;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportResource;
import org.springframework.integration.support.json.Jackson2JsonObjectMapper;
import org.springframework.integration.support.json.JsonObjectMapper;
@Configuration
public class IntegrationConfig {
@Bean
public JsonObjectMapper<?> jsonObjectMapper() {
final ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new JodaModule());
return new Jackson2JsonObjectMapper(mapper);
}
}
@knalli
Copy link
Author

knalli commented Feb 5, 2014

... and do not forget to clean up the classpath. No Jackson1 should be found, otherwise the a custom transformer is required to enforce Jackson2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment