F
F
fijirald2016-01-12 15:45:02
Java
fijirald, 2016-01-12 15:45:02

How is a java web application + Maven + Spring MVC built and compiled?

In Java recently, I understand how web applications are built using Spring MVC, Hibernate and Maven. I collected several hello worlds, it seems to work, but I don’t understand who, what and in what order reads the project files, as a result of which the html page I built opens in the browser.
The process of compiling console applications does not seem to be complicated. javac compiles .java files, the "java" command is fed the name of the main class, in which the entry point is public void main(String[] args).
What happens when we tell the IDE to run our Maven Web Application?
1. The IDE first checks what build system we have? Recognizes it by the folder structure and file names? Or was this information already registered somewhere when creating the project?
2. If I understand correctly, after the build system has created a war or jar file, this file is transferred to the application server. It turns out that every time an incoming request arrives on the glassfish port, the application server matches the requested url with the war nickname that I fed it? And in case of compliance, it climbs inside this file?
3. How does the application server understand that it is necessary to look at the paths to the files in web.xml? I'm using Netbeans and initially by default the project is created without it at all.
4. At what stage of all this action are the objects described in our configs in the tags created in memory?
Just in case, I attach the tree of my project c756b8ae9c4e479dbd4563f4ea4ad63b.PNG
And also the code of my
web.xml

<web-app ...>
         <servlet>
    <servlet-name>mvc-dispatcher</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>mvc-dispatcher</servlet-name>
    <url-pattern>/</url-pattern>
  </servlet-mapping>
  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/mvc-dispatcher-servlet.xml</param-value>
  </context-param>
  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>
</web-app>

mvc-dispatcher-servlet.xml
<beans ...>
    <context:component-scan base-package="ru.domain" />
    <bean
  class="org.springframework.web.servlet.view.InternalResourceViewResolver">
  <property name="prefix">
    <value>/WEB-INF/pages/</value>
  </property>
  <property name="suffix">
    <value>.jsp</value>
  </property>
    </bean>
    <mvc:resources mapping="/resources/**" location="/theme_default/"  />
    <mvc:annotation-driven />
</beans>

and link to Github

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question