Once you are done with the installation, you are ready to develop your first application in Spring. For that, you need to follow five simple steps:
Let's get started with the first step.
Step I: Creating the Bean class:
package org.edureka.firstSpring;
public class StudentBean
{
String name; public String getName()
{ return name; }
public void setName(String name)
{ this.name = name; }
public void displayInfo()
{ System.out.println("Hello: "+ name); }
}
Step II: Create a XML file
Right click on src > New > Other > XML File
Step III: Create the main class
package org.edureka.firstSpring;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class StudentDemo
{
public static void main(String[] args)
{
ApplicationContext appCon=new ClassPathXmlApplicationContext("StudentConfig.xml");
StudentBean factory=(StudentBean)appCon.getBean("studentbean");
factory.displayInfo();
}
}
Step IV: Load the jar files