What happens behind the scenes of deploying a Spring MVC application to tomcat outside of eclipse?

寵の児 提交于 2019-12-04 18:49:05

Deploying a web application to Tomcat is as simple as this (assuming Tomcat is installed)

  1. Bundle your application in a .war with the correct format.
  2. Move the generated .war file to the /webapps directory of your Tomcat installation folder.
  3. Run the /bin/startup.[sh|bat] script in the Tomcat installation folder.

Note that there are intermediate steps you can do to configure the deployment, like changing your context path. Go through the Tomcat documentation for details.

In step 3, Tomcat will extract the .war contents to a directory in the /webapps folder with the same name as your .war file. It will use this as the context path. The script itself launches a java process by putting the WEB-INF/[class|lib|...] onto the classpath along with some Tomcat libraries.

So Eclipse basically does all the steps above for you.

Ultimately you are deploying an web application that means you are deploying a war file to the server. Regardless of using frameworks like spring, struts anything.

SO a web application request starts from web.xml file. SO for spring mvc application, you are mapping all request coming from browser to DispatcherServlet and then this guy is responsible to manage whole life cycle of your application. For more details of how MVC works please see http://docs.spring.io/spring/docs/3.2.x/spring-framework-reference/html/mvc.html

So in order to deploy your application (a war) on server first of all you have to create a war from your source code. You can go to traditional approach to use java given utility like using jar from command prompt or you can use ANT, GRADLE, MAVEN and such build tool that creates war for you in automated way. Spring is not doing anything extra for you. I believe you to research a bit more on how these tools works. Once a war is ready for you, you can simply go to tomcat UI and there you will find options to deploy your war.

I hope it helps you.

All the majic happens in two places.

The first is your 'Servers' directory in the root of your Eclipse Package Explorer. These are your server configuration files that Eclipse will use (mostly) when it creates a new server instance.

The second is in the ./metadata/.plugins/org.eclipse.wst.server.core/ file system directory in your Eclipse workspace. This is where the tomcat application is actually deployed by eclipse.


The Tomcat Documentation is pretty good actually and helps explain how to do deployments. FYI, I do not know many people that use the Manager, from my experience most people deploy their applications by hand.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!