How it works...

The Maven project ch02-xml makes use of both JavaConfig and ServletContainerInitializer, meaning there will be no XML configuration from servlet to Spring 5.0 containers. The BeanConfig class is the ApplicationContext of the project and has an annotation @Configuration, indicating that the class is used by JavaConfig as a source of bean definitions. This is handy when creating an XML-based configuration with lots of metadata.

The project ch02-xml introduces the API org.springframework.web.WebApplicationInitializer, which serves as a handler of org.springframework.web.SpringServletContainerInitializer, the framework's implementation class to the servlet's ServletContainerInitializer. The class SpringServletContainerInitializer is designed to receive notification from WebApplicationInitializer through its method startup(ServletContext). The class ServletContext is a JEE container that manages filters, servlets, and listeners. Once this servlet container acknowledges the no-web.xml status provided by SpringServletContainerInitialize, an option not to use web.xml is acceptable.

On Maven's part, the plugin for deployment must be notified that the project will not use web.xml. This is done through setting the <failOnMissingWebXml> to false inside its <configuration> tag.

The final Spring Web Project directory structure must look like the following structure:

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.220.237.24