Objective
Spring official documents are configured in a purely annotated way, without XML, and only the relevant Java classes are required for project registration and container management.
annotation XML
<Web-app> <!--Configure Contextloaderlistener to use Annotationconfigwebapplicationcontext instead of the default XMLWEBAPPL Icationcontext - <Context-param> <Param-name>Contextclass</Param-name> <Param-value>Org.springframework.web.context.support.AnnotationConfigWebApplicationContext</Param-value> </Context-param> <!--Configuration locations must consist of one or more comma-or space-delimited fully-qualified @Configuration C Lasses. Fully-qualified packages may also is specified for component-scanning - <Context-param> <Param-name>Contextconfiglocation</Param-name> <Param-value>Com.acme.AppConfig</Param-value> </Context-param> <!--Bootstrap The root application context as usual using Contextloaderlistener - <Listener> <Listener-class>Org.springframework.web.context.ContextLoaderListener</Listener-class> </Listener> <!--Declare a Spring MVC dispatcherservlet as usual - <servlet> <Servlet-name>Dispatcher</Servlet-name> <Servlet-class>Org.springframework.web.servlet.DispatcherServlet</Servlet-class> <!--Configure Dispatcherservlet to use Annotationconfigwebapplicationcontext instead of the default Xmlwebapp Licationcontext - <Init-param> <Param-name>Contextclass</Param-name> <Param-value>Org.springframework.web.context.support.AnnotationConfigWebApplicationContext</Param-value> </Init-param> <!--Again, config locations must consist of one or more comma-or space-delimited and fully-qualified @Configu Ration Classes - <Init-param> <Param-name>Contextconfiglocation</Param-name> <Param-value>Com.acme.web.MvcConfig</Param-value> </Init-param> </servlet> <!--Map all requests for/app/* to the dispatcher servlet - <servlet-mapping> <Servlet-name>Dispatcher</Servlet-name> <Url-pattern>/app/*</Url-pattern> </servlet-mapping></Web-app>
Spring Docs "6" "Pure Annotated Mode configuration MVC"