I went to Sheldt's leadership on Java and Spring in Action.If you want to deal with the basic operating tools of the web applications, start with the servelet API profile. http://download.oracle.com/otndocs/jcp/servlet-3.0-fr-oth-JSpec/ ♪ http://download.oracle.com/otndocs/jcp/servlet-3_1-fr-eval-spec/index.html )And when we have a web application, do we have a point of entry?There's no such entry point. There's a silver container that takes your WAR and, if it's all right, starts the life cycle of your web application: sets parameters, alerts listeners, scatters queries into the earrings, passes them through the filters. In fact, the silver container handles the operation of objects that can be described in web.xmland, starting with the third version of the specifications, he should be able to find them without web.xml♪ ...but who creates them? I've read what it's doing to the Spring, within his IoC, DI and his container role, but the Spring must also be launched?That's right, IoC-container Spring. https://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/web/context/support/AnnotationConfigWebApplicationContext.html In your case, scans what he sees. CLASSPATH and creates your bubbles by focusing on the annotations. There's no way to know who's making a copy of this. ApplicationContext and starts its life cycle (see below).The logic is that the initialization of the Spring should occur with a clear or inaccurate challenge to its designers at the entrance, but where is it? Or is he initializing an application server? But how do we tell him to do that?You're very right. From the servelet API 3.0, it was possible not to use web.xml. But the silver container should somehow find out where the code initiating the web application is located. It helps a mechanism known as http://docs.oracle.com/javase/6/docs/technotes/guides/jar/jar.html#Service%20Provider ♪ In short, he's looking for CLASSPATH for the silver container file META-INF/services/javax.servlet.ServletContainerInitializerwhich indicates the implementation of the interface http://docs.oracle.com/javaee/6/api/javax/servlet/ServletContainerInitializer.html?is-external=true ♪ In the case of Spring, it's gonna be great. http://docs.spring.io/autorepo/docs/spring-framework/3.1.x/javadoc-api/org/springframework/web/SpringServletContainerInitializer.html ♪ Let's see without shyness. http://grepcode.com/file/repo1.maven.org/maven2/org.springframework/spring-web/4.2.0.RELEASE/org/springframework/web/SpringServletContainerInitializer.java#SpringServletContainerInitializer ♪ Annotations at the class ad. @HandlesTypes:@HandlesTypes(WebApplicationInitializer.class)
public class SpringServletContainerInitializer implements ServletContainerInitializer {}
Interface contract ServletContainerInitializer the container undertakes to transfer specific implementation to its only method onStartup A collection of classes listed in the annotations @HandlesTypes♪ We only have an interface. WebApplicationInitializerthat's why Glassfish will hand over all the sales found. http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/web/WebApplicationInitializer.html ♪ A copy will be created for each implementation and a method will be created onStartup:for (WebApplicationInitializer initializer : initializers) {
initializer.onStartup(servletContext);
}
And it's yours. SpringInitializer is such a realization. In addition SpringInitializer inherited http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/web/servlet/support/AbstractDispatcherServletInitializer.html ♪ And that's what this is. AbstractDispatcherServletInitializer and Spring launch, creating WebApplicationContext♪ It all worked.PS. Read the specifications and meet the JavaDoc in my response classes. Spring likes to describe in detail all magical mechanisms in key abstract classes and interfaces.