{"action":"created","issue":{"url":"https://api.github.com/repos/spring-projects/spring-boot/issues/2327","labels_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/2327/labels{/name}","comments_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/2327/comments","events_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/2327/events","html_url":"https://github.com/spring-projects/spring-boot/issues/2327","id":54012824,"number":2327,"title":"Jackson XML doesn't use my Serializer - json works","user":{"login":"benneq","id":1627305,"avatar_url":"https://avatars.githubusercontent.com/u/1627305?v=3","gravatar_id":"","url":"https://api.github.com/users/benneq","html_url":"https://github.com/benneq","followers_url":"https://api.github.com/users/benneq/followers","following_url":"https://api.github.com/users/benneq/following{/other_user}","gists_url":"https://api.github.com/users/benneq/gists{/gist_id}","starred_url":"https://api.github.com/users/benneq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benneq/subscriptions","organizations_url":"https://api.github.com/users/benneq/orgs","repos_url":"https://api.github.com/users/benneq/repos","events_url":"https://api.github.com/users/benneq/events{/privacy}","received_events_url":"https://api.github.com/users/benneq/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/spring-projects/spring-boot/labels/bug","name":"bug","color":"fc2929"}],"state":"open","locked":false,"assignee":{"login":"wilkinsona","id":914682,"avatar_url":"https://avatars.githubusercontent.com/u/914682?v=3","gravatar_id":"","url":"https://api.github.com/users/wilkinsona","html_url":"https://github.com/wilkinsona","followers_url":"https://api.github.com/users/wilkinsona/followers","following_url":"https://api.github.com/users/wilkinsona/following{/other_user}","gists_url":"https://api.github.com/users/wilkinsona/gists{/gist_id}","starred_url":"https://api.github.com/users/wilkinsona/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wilkinsona/subscriptions","organizations_url":"https://api.github.com/users/wilkinsona/orgs","repos_url":"https://api.github.com/users/wilkinsona/repos","events_url":"https://api.github.com/users/wilkinsona/events{/privacy}","received_events_url":"https://api.github.com/users/wilkinsona/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/spring-projects/spring-boot/milestones/33","labels_url":"https://api.github.com/repos/spring-projects/spring-boot/milestones/33/labels","id":902476,"number":33,"title":"1.2.2","description":"","creator":{"login":"philwebb","id":519772,"avatar_url":"https://avatars.githubusercontent.com/u/519772?v=3","gravatar_id":"","url":"https://api.github.com/users/philwebb","html_url":"https://github.com/philwebb","followers_url":"https://api.github.com/users/philwebb/followers","following_url":"https://api.github.com/users/philwebb/following{/other_user}","gists_url":"https://api.github.com/users/philwebb/gists{/gist_id}","starred_url":"https://api.github.com/users/philwebb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/philwebb/subscriptions","organizations_url":"https://api.github.com/users/philwebb/orgs","repos_url":"https://api.github.com/users/philwebb/repos","events_url":"https://api.github.com/users/philwebb/events{/privacy}","received_events_url":"https://api.github.com/users/philwebb/received_events","type":"User","site_admin":false},"open_issues":24,"closed_issues":47,"state":"open","created_at":"2014-12-13T03:31:15Z","updated_at":"2015-02-09T22:06:19Z","due_on":"2015-02-19T08:00:00Z","closed_at":null},"comments":9,"created_at":"2015-01-12T01:15:57Z","updated_at":"2015-02-10T12:11:37Z","closed_at":null,"body":"I've written a small Serializer for MongoDB's ObjectId:\r\n```\r\npublic class ObjectIdSerializer extends StdSerializer<ObjectId> {\r\n\tpublic static final ObjectIdSerializer INSTANCE = new ObjectIdSerializer();\r\n\tprivate ObjectIdSerializer() { super(ObjectId.class); }\r\n\t@Override public void serialize(ObjectId value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonGenerationException {\r\n\t\tjgen.writeString(value.toHexString());\r\n\t}\r\n}\r\n```\r\n\r\nAnd a SimpleModule:\r\n```\r\n@Component\r\npublic class CommonJacksonModule extends SimpleModule {\r\n\tpublic CommonJacksonModule() {\r\n\t\tsuper(new Version(1, 0, 0, null, null, null));\r\n\t\taddSerializer(ObjectId.class, ObjectIdSerializer.INSTANCE);\r\n\t}\r\n}\r\n```\r\n\r\nWhen using Accept=application/json it works as expected and I get something like \"5498374f44ae6f110dd0abcd\". But using Accept=application/xml I get something like:\r\n```\r\n<new>false</new>\r\n<timeSecond>1419261775</timeSecond>\r\n<inc>231792298</inc>\r\n<machine>1152282385</machine>\r\n<time>1419261775000</time>\r\n<date>2014-12-22T15:22:55.000+0000</date>\r\n<timestamp>1419261775</timestamp>\r\n```\r\n\r\nWhat's the problem here?"},"comment":{"url":"https://api.github.com/repos/spring-projects/spring-boot/issues/comments/73689582","html_url":"https://github.com/spring-projects/spring-boot/issues/2327#issuecomment-73689582","issue_url":"https://api.github.com/repos/spring-projects/spring-boot/issues/2327","id":73689582,"user":{"login":"wilkinsona","id":914682,"avatar_url":"https://avatars.githubusercontent.com/u/914682?v=3","gravatar_id":"","url":"https://api.github.com/users/wilkinsona","html_url":"https://github.com/wilkinsona","followers_url":"https://api.github.com/users/wilkinsona/followers","following_url":"https://api.github.com/users/wilkinsona/following{/other_user}","gists_url":"https://api.github.com/users/wilkinsona/gists{/gist_id}","starred_url":"https://api.github.com/users/wilkinsona/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wilkinsona/subscriptions","organizations_url":"https://api.github.com/users/wilkinsona/orgs","repos_url":"https://api.github.com/users/wilkinsona/repos","events_url":"https://api.github.com/users/wilkinsona/events{/privacy}","received_events_url":"https://api.github.com/users/wilkinsona/received_events","type":"User","site_admin":false},"created_at":"2015-02-10T12:11:37Z","updated_at":"2015-02-10T12:11:37Z","body":"I see declaring your own `ObjectMapper` as saying that you don't want Boot to automatically apply any configuration to it. With that  in mind, there's a couple of options (at least) for applying `Module` beans to an `ObjectMapper`:\r\n\r\n1. They could use `Jackson2ObjectMapperBuilder` to configure their `ObjectMapper`. That'll apply any `Module` beans (and all the other Jackson configuration). They can then customise the `ObjectMapper` as appropriate to deviate from the \"global\" Jackson configuration.\r\n2. They could add the modules themselves using `objectMapper.registerModules()` having retrieved them using an autowired List<Module>, for example."}}