Looking at STS log for Spring MVC Project

STS comes with several tools. In this post, I am going try to explain how to look into the activities of a basic Spring Web MVC project created by STS.

  1. Set up STS and Pivotal tc Server and start STS in Spring prospective.
  2. Select File -> New -> Spring Legacy Project -> Spring MVC Project
  3. Select a name e.g.; SimpleSpring and package e.g.; com.mycompany.myapp and click Finish.
  4. STS will build the maven project and after some time the error should go away. If it does not, right click the project and select Maven -> Update Project
  5. Right click the project and select Run As -> Run on server. Select Pivotal tc Server Developer Edition. If Pivotal server does not work, you can select Manually define a new server, select Pivotal Server and finish the wizard by clicking Next.
  6. When you start Pivotal tc Server, make sure in ‘Run On server’ dialog box, the project is on the Configured side. Press Finish to deploy the application in the server.
  7. If you visit http://localhost:8080/myapp/ in your browser you should see the following page.


If we see the console, lots of interesting things are happening.


  1. First the ContextLoader is loaded. If we see src/main/webapp/WEB-INF/web.xml file the listener tag loads a listener for this context. Any changes or addition of resources to this context is read from /WEB-INF/spring/root-context.xml file. As the comment on this configuration says, this file is loaded by Spring’s root container. The root container manages beans that can be used thought the application.
  2. If we go back to the console the beans defined in the root-context.xml file is loaded using XmlBeanDefinitionReader.
  3. After the root context is loaded, DispatcherServer which is the front controller of the application is loaded with similar settings. The configuration is read from servlet-context.xml file.
  4. Other log information in the console are mostly because of servlet-context.xml configuration. The annotation-driven and context:component-scan triggers JSR-250 and JSR-330. These are tags for annotation and auto-wired dependency resolution.
  5. This file also triggers resources mapping.
  6. If we visit com.mycompany.myapp.HomeController the use of Model and Locale can be seen.
  7. DefaultListableBeanFactory pre-loads several beans necessary for handling the application. Similarly RequestMappingHandlerMapping maps appropriate request, HTTP method and other necessary parameters to the controller.



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s