Spring-Spring Core4 Comments

This tutorial shows you how to create a simple hello world example in Spring 3.0.

Technologies used in this article :

  1. Spring 3.0.5.RELEASE
  2. Maven 3.0.3
  3. Eclipse 3.6
  4. JDK

P.S Spring 3.0, at least JDK 1.5 is required to work.

  • Prepare Spring 3.0 dependencies in Maven

Add the Spring 3.0 dependencies listed below in Maven’s pom.xml file. The Spring dependencies are available for download via Maven central repository.

pom.xml :

  • Spring Bean

Just a POJO with a name we will inject value later
HelloWorld : 

  • Spring bean configuration file

spring-core.xml : 

(If there is only one bean of the class HelloWorld will be declared in our application , bean id should be same as class name with first character is lowercase as a good convention to be followed)

  • Run Spring

To make it simple as possible, to init Spring IOC container, we  will directly init it like below code :

InitClass :

You will receive the output :

  • Summary

In this example , you just learned very basics function of Spring like how to create a bean in Spring, and how to inject some value into bean property when init it.Hope you enjoy it and ready for my next post of Spring Core




4 Comments on this article

Add a comment