How To Install Spring IDE Eclipse Plugin

Spring IDE is a useful graphical development tool. It can make Spring application development easy. This article will show you how to install it as an Eclipse plugin.

1. Install Spring Plugin From Eclipse Marketplace

  1. Open Eclipse, click the menu item Help —> Eclipse Marketplace.
  2. Input the keyword Spring IDE in the popup Eclipse Marketplace dialog Find input text box, click the Go button to search the plugin.
  3. Select the sts ( Spring Tools Suite ) eclipse plugin in the search result list.
  4. Click the Install button to install it. After a while, it will list all the sts ide required plugins. Click the checkbox to choose them all and click the Confirm button to continue.
  5. Select the checkbox Accept terms of license agreement in the next wizard, click the Finish button.
  6. When the sts plugin installation complete, you need to restart eclipse.
  7. After restart, you can see the eclipse ide Welcome page that shows the Spring IDE link (click to Create a new Spring project) , Spring Tool Suite Dashboard link( click to See the Tool Suite Dashboard) in it.
  8. If you do not see the eclipse Welcome page, you can click the eclipse Help —> Welcome menu item to show it.

2. Create Spring Java Project

  1. Open Eclipse, click File —> New —> Project menu item.
  2. Choose Spring / Spring Legacy Project ” in the popup New Project dialog. Click Next.
  3. Input Project name and browse to select Location ( project saved directory ) in the Spring Legacy Project wizard dialog.
  4. Select Simple Projects / Simple Spring Maven in the Templates drop-down list.
  5. After click Finish button, you can see the project listed in Eclipse left panel. Because we choose “Simple Spring Maven” in step 3. So all Spring related jars has been added in the project.
    spring project in eclipse left panel
  6. If you choose “Simple Java” in step 3, you need to add the jars manually. You can click here to download the latest jars.
    download spring dependency jars page
  7. After download, unzip it to a local folder. Then add related jars into java project. You can read Spring Hello World Example Use Maven And Eclipse to learn how to add the jars to project.
  8. Spring use commons-logging by default, so you need to click here to download commons-logging jar lib file. Then add it to project build path.
    commons logging download page

3. Create HelloWorld Java Bean.

  1. Right click src/main/java, click ” New —> Class ” in the popup menu.
  2. Input package name, class name in the popup dialog as below.
    create hello world java bean
  3. Input below java code in HelloWorld.java. Please note all the private instance field should has a set and get method.
    public class HelloWorld {
    	
    	private String firstName;
    	
    	private String lastName;
    
    	public String getFirstName() {
    		return firstName;
    	}
    
    	public void setFirstName(String firstName) {
    		this.firstName = firstName;
    	}
    
    	public String getLastName() {
    		return lastName;
    	}
    
    	public void setLastName(String lastName) {
    		this.lastName = lastName;
    	}
    	
    	public void sayHello()
    	{
    		System.out.println("Hello " + this.getFirstName() + " " + this.getLastName());
    	}
    }
    

4. Create Spring Bean Configuration Xml File.

  1. Right click src/main/resources in left panel, Click ” New —> Others” in popup menu list.
  2. Choose ” Spring Bean Configuration File ” in popup dialog. Click Next.
    create spring bean configuration file
  3. Input BeanSettings.xml in configuration file name text box, please note the xml file should be saved in src/main/resources directory. Click Next.
    input spring bean configuration file name
  4. Select related xsd in next dialog. We just select beans xsd.
    spring bean configuration file xsd selection
  5. Click Next, Finish to close the wizard. You can see BeanSettings.xml has been created in left project tree.
    BeanSettings.xml file craeted in left project tree panel

5. Add Java Bean To Bean Configuration File.

  1. Double click BearSettings.xml file just created.
  2. Click “New Bean” button in right panel “beans” tab.
    add new java bean in spring configuration xml file
  3. Input bean id in the popup dialog as below. Click Browse button to select HelloWorld class we just created in step 3. Click Next.
    input bean id and classselect spring bean class
  4. Add following two properties in next dialog.
    add spring bean properties
  5. Click Finish, Now click Source tab at the bottom, you can see bean definition in xml file.
    bean definiton in xml file

6. Invoke HelloWorld Java Bean

  1. Create class com.dev2qa.example.spring.InvokeHelloWorldBean.
  2. Add below java code in it.
    public static void main(String[] args) {
        /* Initiate Spring application context. */
        ApplicationContext springAppContext = new ClassPathXmlApplicationContext("BeanSettings.xml");
    
        /* Get HelloWorldBean by id. */
        HelloWorld helloWorldBean = (HelloWorld) springAppContext.getBean("helloWorldBean");
    		
        /* Set bean field value. */
        helloWorldBean.setFirstName("Lucky");
    		
        /* Call bean method. */
        helloWorldBean.sayHello();
    }
    
  3. Run it, then you can see the below output.
    spring helloworld java bean sayHello method output
0 0 vote
Article Rating
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

1 Comment
Newest
Oldest Most Voted
Inline Feedbacks
View all comments
Shamsher Baloch
Shamsher Baloch

simple maven project does not any thing EXCEPT MANIFEST.MF in file explorer in eclpise in linux mint 19.2 cinnemon. I don’t understand why please, help me to sort out.

1
0
Would love your thoughts, please comment.x
()
x