Webcam Chat Satellite Internet QuickBooks Advice international calling cards international phone cards
Submit Your Blog Feedback Request Article Print Email

Introduction to Spring IDE 2.0

Author : TusharJoshi
Topic : spring  
Pages :

Simple Spring Beans Example

Let us explore the Spring IDE 2.0 features through a sample application. Spring IDE has contributed Spring Project Wizard in the New Project option of Eclipse. We will start our example application with a demo project which will use Spring Project Wizard.

Open the new project dialog box by choosing File Menu > New Option and Choose the Spring Project Node below the Spring Node in the Wizards tree view. Click Next to proceed.

You will see the New Spring Project Dialog box. This is just like the New Java Project Dialog box in a simplified version. Here type the project name as "springide-demo" and keep all the options at their default values. Now click Finish button.

This will create a new project with Spring Project Nature in the Eclipse IDE. Spring Nature provides visual indicators in the Package Explorer view which will be shown in Java Perspective. Note the S symbol attached to the project name with the default project icon. This is Spring IDE's way to indicate the Spring Project Nature applied to this project.

Create a package named "com.company.demo" and one class in this package "Developer" with two private variables with their setter and getter methods. You can generate the setter getter methods through the eclipse source menu using the generate getter and setters option.


/**
 * 
 */
package com.company.demo;

/**
 * @author Tushar Joshi
 * 
 */
public class Developer {

	private String name;
	private int experienceYears;

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public int getExperienceYears() {
		return experienceYears;
	}

	public void setExperienceYears(int experienceYears) {
		this.experienceYears = experienceYears;
	}
}

The class when opened in Eclipse code window will look like as below. This class is a Plane Old Java Object (POJO). Spring Framework leverages the use of POJO through declarative beans configuration files. We will use this POJO which will be injected in our application through Spring Classes using the bean definition file.

Spring IDE provides a wizard for creation of the beans configuration file. Choose the New options in the File menu again and the Other option to select the Spring Node and the Spring Bean Definition node to start the Spring Bean configuration wizard. Click Next to proceed.

New Spring Bean Definition file dialog will be shown where you will have to type a name for the bean definition / configuration file. Type name demo-beans.xml in the File Name text box. Choose "src" folder to keep the bean definition file. Click Next to proceed.

The spring bean definition file wizard included the beans XSD by default while creating the template for the bean definition file. For additional schemas you will have to choose the schema from the given list of available spring schemas. We will keep all the options unchecked as we want to write a simple spring beans application which requires only the core beans XSD which is by default added in the template.

Submit Your Blog Feedback Request Article Print Email

Java / J2EE Tutorials

Spring Framework

Hibernate Framework

JSF Framework

Struts Framework

Java Server Pages(JSP)

Servlets

Java / J2EE Design Patterns

SCJP

SCEA


Favorites
Latest QnA
SCJD Tips
When we start a thread by applying start() method on it ,how does it knows that to execute run()method?
About Wrapper class in Java
How to configure weblogic 7.0 in MyEclipse?
Static Block and Static Initializer in Java

JavaBeat Website (2004-2009), India
javabeat | about us | useful resources
Copyright (2004 - 2009), JavaBeat