Bootstrapping and Configuring Spring with no XML, only Java in a Web Application..

.. using WebApplicationInitializer! Configuration in Java as well! RootContext and Webapp Context! Component scan enabled!
import org.springframework.web.WebApplicationInitializer;
import org.springframework.web.context.ContextLoaderListener;
import org.springframework.web.context.support.AnnotationConfigWebApplicationContext;
import org.springframework.web.servlet.DispatcherServlet;
 
import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.ServletRegistration;
 
@SuppressWarnings("unused")
public class Bootstrap implements WebApplicationInitializer {
 
    @Override
    public void onStartup(ServletContext container) throws ServletException {
 
        container.getServletRegistration("default").addMapping("/resource/*");
 
        AnnotationConfigWebApplicationContext rootContext
                = new AnnotationConfigWebApplicationContext();
        rootContext.register(MyRootContextConfiguration.class);
        container.addListener(new ContextLoaderListener(rootContext));
 
        AnnotationConfigWebApplicationContext servletContext =
                new AnnotationConfigWebApplicationContext();
        servletContext.register(MyServletContextConfiguration.class);
 
        //This is for bootstrapping Spring:
        ServletRegistration.Dynamic dispatcher = container.addServlet(
                "springDispatcher", new DispatcherServlet(servletContext)
        );
        dispatcher.setLoadOnStartup(1);
        dispatcher.addMapping("/");
    }
 
}
 
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Controller;
 
@Configuration
@ComponentScan(
        basePackages = "biz.tugay.site",
        excludeFilters = @ComponentScan.Filter(Controller.class)
)
public class MyRootContextConfiguration {
}
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Controller;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
 
@Configuration
@EnableWebMvc
@ComponentScan(
        basePackages = "biz.tugay.site",
        useDefaultFilters = false,
        includeFilters = @ComponentScan.Filter(Controller.class)
)
public class MyServletContextConfiguration {
}