Steps to create spring Application

Here, we are going to take in the basic strides to make the first spring application. To run this application, we are not utilizing any IDE. We are essentially utilizing the order brief.

Steps to create spring application

Let's see the 5 steps to create the first spring application.

  • create the class
  • create the xml file to provide the values
  • create the test class
  • Load the spring jar files
  • Run the test class

Create Java class

This is the straight forward java bean class containing the name property just. This is straightforward bean class, containing one and only property name with its getters and setters technique. This class contains one additional technique named displayInfo() that prints the under study name by the welcome message.

package com.javatportal;

public class Student {
private String name;

public String getName() {
	return name;

public void setName(String name) { = name;

public void displayInfo(){
	System.out.println("Hello: "+name);


Create the xml document

If there should be an occurrence of myeclipse IDE, you don't have to make the xml record as myeclipse does this for yourselves. The bean component is utilized to characterize the bean for the given class. The property sub element of bean determines the property of the Student class named name. The quality indicated in the property component will be set in the Student class object by the IOC holder.

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

<bean id="studentbean" class="com.javatportal.Student">
<property name="name" value="Mithi"></property>


Create the test class

Make the java class e.g. Test. Here we are getting the object of Student class from the IOC holder utilizing the getBean() system for BeanFactory.

package com.javatportal;

import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.xml.XmlBeanFactory;

public class Test {
public static void main(String[] args) {
	Resource resource=new ClassPathResource("applicationContext.xml");
	BeanFactory factory=new XmlBeanFactory(resource);
	Student student=(Student)factory.getBean("studentbean");

Load the container records needed for spring system

There are primarily three jug records needed to run this application.

  • org.springframework.core-3.0.1.RELEASE-A
  • org.springframework.beans-3.0.1.RELEASE-A

Run the test class

Presently run the Test class.