Well, for example:
@Configuration @ImportResource("classpath:META-INF/ann-config.xml") @ComponentScan(basePackageClasses = {MyController.class}) public class Initializer implements WebApplicationInitializer { public void onStartup(ServletContext servletContext) throws ServletException { AnnotationConfigWebApplicationContext ctx = new AnnotationConfigWebApplicationContext(); ctx.register(WebConfig.class); ctx.setConfigLocation("classpath:META-INF/ann-config.xml"); servletContext.addListener(new ContextLoaderListener(ctx)); ctx.setServletContext(servletContext); ServletRegistration.Dynamic servlet = servletContext.addServlet("dispather", new DispatcherServlet(ctx)); servlet.addMapping("/"); servlet.setLoadOnStartup(1); } } Actually the question: What are the weaknesses of this approach compared to the XML configuration? What prompted to raise the topic? In one company, one of the specialists in an authoritative position as an architect, hinted that this is considered bad form. To the question Who is considered? response by the java community. What do you think?