Spring First Example

  • Step-1 Download Spring framework binaries from http://www.springsource.org/download
  • Step-2 Create java project by click on new >> project >> java project >> enter project name >> ok.
    Spring Project Add

  • Step-3 Add Spring jars to classpath by right click on project >> properties >> java build path >> libraries >> add external jars >> ok.

    Spring Jar add

  • Step-4 Create java class by right-click on project >> New >> class >> class name >> finish.

  • Adding Spring Class

  • Step-5 Create another java class by right-click on project >> New >> class >> class name >> finish.

  • Adding Spring Class next

  • Step-6 Create XML file by right-click on project src folder >> New >> other >> XML >> XML file >> enter file name Beans.xml >> finish.

  • Adding Spring xml

HelloSpring.java File

package com.jtechies;

public class HelloSpring {
	private String message;
	   public void setMessage(String message){
	      this.message  = message;

	   public void getMessage(){
	      System.out.println("Your Message : " + message);

Test.java File

package com.jtechies;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support

public class Test {
   public static void main(String[] args) {
      ApplicationContext context = new 
      HelloSpring obj = (HelloSpring) 

Beans.xml file

<?xml version="1.0" encoding="UTF-8"?>

<beans xmlns="http://www.springframework.org/schema/beans"

   <bean id="helloSpring" class="com.jtechies.HelloSpring">
       <property name="message" 
       	value="Welcome to the World of spring!"/>



Your Message : Welcome to the World of spring!