Is this possible? I have a service that may need to marshal objects from a significant number of projects, each with several object factories. I currently only specify a few specific classes that need to be marshalled on a regular basis. Can I add a list of contexts for the other projects, as well as keep my current list of classes? Or do I have to do one or the other?
With so many individual classes that may need to be marshalled, is it smarter to just simply use a list of contextpaths?
No you can not combine these approaches, it is checked against such usage in
public final void afterPropertiesSet()in the Jaxb2Marshaller class. However there is in the Spring 3.1 another property that can be used, it is called packagesToScan, it accepts wildcards (com.foo.*.schemas), you can also provide a list of such expressions.But one thing you should know, it doesn’t work properly for classes without well known annotation
@XmlRootElementbecause of the methodprivate boolean supportsInternal(Class<?> clazz, boolean checkForXmlRootElement)in the Jaxb2Marshaller, it will return false for elements without this annotation.Good luck.