In our application we have a rapidly growing number of JAXB2 annotated classes. It is a right pain to add these classes manually to the "classesToBeBound" property in the Jaxb2Marshaller. Given that other components (I'm looking at you Hibernate : AnnotationSessionFactoryBean) have the ability to automatically add classes from packages that match annotations, why not then for the Jaxb2Marshaller (having to key in the classes manually is so old skool).
I've extended Jaxb2Marshaller (file attached) that scans on the classpath for appropriately annotated classes. Please do review and I hope that this can be incorporated into the next release. I'm happy to make changes to the codebase if required to bring it up to Spring coding standards.
It's a pity that afterPropertiesSet is marked as Final in Jaxb2Marshaller since I can't override that method to set up the setClassesToBeBound before then calling the super afterPropertiesSet. Currently as the code stands, I have to provide a dummy setClassesToBeBound and setLazyInit to be true. This dummy is then replaced by overriding the getJaxbContext. I think this needs rewriting.
An example of use: