I have a plain jane servlets web application, and some of my classes have the following annotations:
@Controller
@RequestMapping(name = \"/blog/\")
public cl
The following code worked for me, the below example uses Java 11 and spring ClassPathScanningCandidateComponentProvider. The usage is to find all classes annotated with @XmlRootElement
public static void main(String[] args) throws ClassNotFoundException {
var scanner = new ClassPathScanningCandidateComponentProvider(false);
scanner.addIncludeFilter(new AnnotationTypeFilter(XmlRootElement.class));
//you can loop here, for multiple packages
var beans = scanner.findCandidateComponents("com.example");
for (var bean : beans) {
var className = bean.getBeanClassName();
Class clazz = Class.forName(className);
//creates initial JAXBContext for later usage
//JaxbContextMapper.get(clazz);
System.out.println(clazz.getName());
}
}