문제

I'm converting my guice application to a spring based on because of issues I found with the @transaction annotation. When doing so, I came to a issue with the configuration of a custom objectmapper with spring/resteasy. I want to register the hibernate4Module (fasterxml jackson) and a custom deserializer.

I have found many solution when using spring mvc, but I'm not using spring mvc. I'm looking at the resteasyboostrap class, since there you have control over you factory, but I don't know how to register my new SimpleModule there.

Anyone with any experience? When I'm searching the internet, it seems nobody is trying to do the same thing. Perhaps I'm looking in the wrong places?

도움이 되었습니까?

해결책

This one was eventually an easy one to fix. Remove the resteasy-jackson provider and write a custom class that you annotate with the spring @Component annotation. Jax-RS picks up the provider and uses the object mapper in the provider. I was searching in the implementation, but the answer was in the jax-rs api.

@Component
@Provider
@Consumes({"application/*+json", "text/json"})
@Produces({"application/*+json", "text/json"})
public class JacksonProvider extends JacksonJsonProvider {
    public JacksonProvider() {
        setMapper(new CustomObjectMapper());
    }
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top