Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Customised ObjectMapper not recognized #1051

Closed
milanov opened this issue Nov 12, 2015 · 3 comments
Closed

Customised ObjectMapper not recognized #1051

milanov opened this issue Nov 12, 2015 · 3 comments
Labels
Milestone

Comments

@milanov
Copy link

milanov commented Nov 12, 2015

I'm using Springfox 2.2.2 in a Spring Boot 1.3.0.M4 application. I have configured a custom ObjectMapper bean and marked it as primary. However, springfox doesn't recognize it and shows some default mappings.

@Bean
@Primary
public ObjectMapper objectMapper() {
    ObjectMapper mapper = new ObjectMapper();
    mapper.registerModule(new JavaTimeModule(), new MoneyModule());
    mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
    return mapper;
}

I have read all the issues regarding this here and also I've read the description on the website about configuring the OM, but I can't find a working solution. I tried to register a ApplicationListener<ObjectMapperConfigured> listener and I debugged that I receive two OM instances, the first one being the one I have configured and the second some default one. I tried to apply the same configurations in the listener (on both mappers), but the types continue to be shown as if I use a non-configured default ObjectMapper.

@pacitu
Copy link

pacitu commented Nov 12, 2015

+1

@dilipkrish dilipkrish added this to the 2.3.0 milestone Nov 15, 2015
@dilipkrish dilipkrish added bug and removed question labels Nov 15, 2015
@dilipkrish dilipkrish modified the milestones: 2.4.0, 2.3.0 Nov 15, 2015
@dilipkrish
Copy link
Member

@milanov yeah this is probably the hardest problem that we've been trying to solve, can never get it quite right. Any ideas on how to solve it for your use case? PR perhaps?

@rockytriton
Copy link

I don't know if this is related, but i had an issue with SpringBoot and object mapper. It turned out that my application was initializing spring boot twice and causing lots of problems with springfox. In my Application onStartup() method, i created a servlet and then called super.onStartup() which caused the problem. After fixing that it resolved all my object mapper issues.

If you see the "Spring Boot" ascii banner displayed twice you might have the same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants