I am writing a RESTful web service using JAXB and Spring MVC. In my Spring context takes care of a lot of helpful stuff for me, but it registers its own JAXB marshaller and I can't find a way to add properties to it (like a NamespacePrefixMapper or schema location).
Is there a way to override the default marshaller configured in or set properties on it?
<mvc:annotation-driven>
is essentially a "macro" that registers a bunch of fixed config options. You can see what it does in the source of the rather dense AnnotationDrivenBeanDefinitionParser
class.
Of particular interest here is that it registers a AnnotationMethodHandlerAdapter
and injects a whole series of components into it, some of which you'll need, many of which you won't.
<mvc:annotation-driven>
doesn't offer much in the way of customisation, though, so if you want to change what it does, you need to remove it from your context, and declare your own AnnotationMethodHandlerAdapter
, configured the way you want.
The JAXB marshaller is injected into the messageConverters
property of AnnotationMethodHandlerAdapter
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With