Created
February 5, 2014 15:09
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
... and do not forget to clean up the classpath. No Jackson1 should be found, otherwise the a custom transformer is required to enforce Jackson2.