Spring IDE

DZone 's Guide to

Spring IDE

· ·
Free Resource

spring ide is an eclipse plug-in that helps in developing spring application. first we will see how to install the spring ide and later we will create our first spring project using it. i am using eclipse 3.4.1 version to demonstrate this.

to install spring ide, go to help -> software updates.

click the " add site " button and enter " http://springide.org/updatesite " in the add site popup.

select all the spring ide features and click install.

once the installation is complete you are done. now let's see how to create the hello world example using the spring ide.

first create a spring project, go to file -> new -> project.

select spring project and click next.

enter the project name and click finish.

the "s" in the upper right corner indictes it is a spring project.

right click the src package and create a new package " com.vaannila ". create the following helloworld class

package com.vaannila;

public class helloworld {

    private string message;
    public void setmessage(string message) {
        this.message = message;
    public void display()

the helloworld class has a message property and its value is set using the setmessage() method. this is called setter injection. instead of directly hard coding the message, we inject it through an external configuration file. the design pattern used here is called dependency injection design pattern and it is explained in detail in the next example. ( spring dependency injection )the helloworld class also has a display() method to display the message.

now we have created the helloworld bean class, the next step is to add an entry for this in the bean configuration file. the bean configuration file is used to configure the beans in the spring ioc container. to create a new bean configuration file right click the src folder and select new -> spring bean configuration file.

enter the bean name and click next.

select the beans option and click finish.

now the spring configuration file is created. add the following code to created an entry for the helloworld bean class.

<?xml version="1.0" encoding="utf-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xsi:schemalocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">

    <bean id="helloworld" class="com.vaannila.helloworld">
        <property name="message" value="hello world!"></property>


the id attribute of the bean element is used to give a logical name to the bean and the class attribute specifies the fully qualified class name of the bean. the property element within the bean element is used to set the property value. here we set the message property to " hello world! ".

if you want to display a differnt message, the only change you need to is to change the value of the message in the bean configuration file. this is one of the main benefits of using the dependency injection design pattern, this makes the code loosely coupled.

to dispaly the message, create the following helloworldapp class.

package com.vaannila;

import org.springframework.context.applicationcontext;
import org.springframework.context.support. classpathxmlapplicationcontext;

public class helloworldapp {
    public static void main(string[] args) {
        applicationcontext context = new classpathxmlapplicationcontext("beans.xml");
        helloworld helloworld = (helloworld) context.getbean("helloworld");


first we instantiate the spring ioc container with the bean configuration file beans.xml . we use the getbean() method to retrive the helloworld bean from the application context and call the display() method to display the message in the console.

the figure shows the final directory structure of the hello world example.

add the following jar files to the classpath.


to execute the example run the helloworldapp file. the " hello world! " message gets printed on the console.

you can download and try the spring hello world example by clicking the download link below.

source: download

source + lib: download


Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}