I'm planning to replace jackson-jaxrs-json-provider
with MOXy thing. I tried to comment on MOXy is the New Default JSON-Binding Provider in GlassFish 4 and had no luck.
My stack is as follows.
Jersey
Spring
MyBatis
I'm using jackson-jaxrs-json-provider
and providing a custom ContextResolver
.
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
//@Provider
public class ObjectMapperContextResolver
implements ContextResolver<ObjectMapper> {
public ObjectMapperContextResolver() {
super();
objectMapper = new ObjectMapper()
.configure(MapperFeature.USE_WRAPPER_NAME_AS_PROPERTY_NAME, true);
objectMapper.registerModule(new JaxbAnnotationModule());
}
@Override
public ObjectMapper getContext(final Class<?> type) {
return objectMapper;
}
private final ObjectMapper objectMapper;
}
My questions are
- which maven artifact should I depend on for replacing
jackson-jaxrs-json-provider
? Is itcom.eclipsesource.jaxrs:provider-moxy
? - Is it the right way to work as described in above link? Note that my module is not for full featured AS, but for Tomcat.
You should be using
Not really sure what you're asking here, but the
jersey-media-moxy
artifact doesn't use/depend on Jackson. So your use ofObjectMapper
would not work.ContextResolvers
with MOXy (JSON), would consist of usingMoxyJsonConfig
.For other configurations of this artifact, the link you provided is a good place, and also The Jersey User Guide for working with MOXy