I am not sure how to register my custom objectMapper that I created below as a bean and inject it as dependency into other objects via constructor, or Autowire
@SpringBootApplication
public class DemoApplication {
@Bean
//how to register it as a bean here and inject wherever I need to via @Inject or @Autowire
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
@Provider
public class ObjectMapperProvider implements ContextResolver<ObjectMapper> {
private final ObjectMapper objectMapper = new ObjectMapper();
public ObjectMapperProvider() {
this.objectMapper.disable(DeserializationFeature.READ_ENUMS_USING_TO_STRING);
}
@Override
public ObjectMapper getContext(final Class<?> type) {
return objectMapper;
}
}