Spring 3 Hello World Example – Quick Introductory Tutorial

14 Flares Twitter 0 Facebook 0 Google+ 13 Pin It Share 0 LinkedIn 1 Filament.io 14 Flares ×

This tutorial helps you in quickly setting up a spring 3 development environment and explains how to create a simple hello world program using Spring 3.

Technologies used

  • Spring 3.2.7
  • Maven ( 3.1.1 )
  • Eclipse ( latest version/ Eclipse Juno )
  • JDK 1.5 or Above

In this Hello World Tutorial we are using Maven as the build tool and hence we will start with creating a maven project.

Generate Project Structure using Maven

Open a Command prompt and type

Issuing the above command will generate a standard Java project structure.Please note that you should have already installed maven in your machine. If you haven’t installed maven, please refer [Maven Download] to download and set it up properly.

Next step is to convert this to an eclipse project.  To do so, change to the Spring3HelloWorld Directory and run

If all goes well, we now have a Java project structure that is compatible with eclipse. This project can be loaded in eclipse. Use the Import project option (File -> Import) of eclipse to load the project.

There will be a pom.xml file in the project structure and this is where we need to specify the Spring dependencies so that maven will resolve those automatically during the build.

Add Spring Dependency

If you are using Eclipse IDE (Eclipse Juno in this case) and haven’t configured Maven integration in Eclipse, you should do so now. You can do that in eclipse by Help -> Eclipse Marketplace and in the search box type Maven and from the results select the one with title “Maven Integration for Eclipse( Juno and newer)” and click install. Complete the setup and you are ready. You need to restart Eclipse after this.

First Spring Bean

Spring Configuration File

This file can be given any name you want. For this tutorial we name it beanconfig.xml. This file you can place in any folder but make sure that the particular folder is in the build path of the eclipse project.

Java Client

Spring setup is complete and the first Spring bean is ready. Next step is to invoke the bean and test our first bean.


Hello World: Spring 3 in Action, This is bean with name Hello

Tips: Make sure that all the required jars are on the build path.


Spring framework

  • Carlos Barros

    i hate maven. its the most nightmare tool ever. thats why rails are gaining so much power these days. you must install maven to build a helloworld sample cmon!

  • dave Snothere

    Rails is for rookies.

  • umesh

    After four hours of all installations and setup ….i got the output…Thank you …Learnt something new today