I am trying to use Jaxb2Marshaller to marshal a set of java classes using spring. I know this can be done using the following code
<bean id="jaxbMarshaller" class="org.springframework.oxm.jaxb.Jaxb2Marshaller">
<property name="classesToBeBound">
<list>
<value>com.example.test1</value>
<value>com.example.test2</value>
</list>
</property>
</bean>
What I would like to do is instead of specifying a list of classes, I would like to specify just the package name containing all the classes ( in the above case com.example).
Does anyone know of a way to do this, or any other way which does not require me to list all the classes. any help would be appreciated !
Thanks.
From Spring 3.1 (i think) you can use also the packagesToScan property, which accepts wildcards. It just doesn't work with elements without the @XmlRootElement
annotation, just like the contextPath property. These need generated object-factory.
Could look like:
<property name="packagesToScan">
<list>
<value>com.test.*</value>
<value>com.*.test</value>
</list>
</property>