Start Spring with Maven & Eclipse


First download the latest binaries from apache. Then extract it and copy to C:Program Files. Now set the environmental variables as follows.

Then edit the path variable as follows .

Now verify the installation.

Then , create a project using maven.

Type the following command .

mvn archetype:generate -DgroupId=com.supun.common -DartifactId=SpringExamples 
-DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false

This will generate the folder with pom.xml file. Now open the pom.xml file. Edit the file so as it looks like below.

<project xmlns:xsi="" xmlns="" xsi:schemalocation="">



Then convert this project into an eclipse project using mvn eclipse:eclipse. Then import it as follows.

Here is the folder structure.

Now add the following classes to the App class.

package com.supun.common;
import org.springframework.context.ApplicationContext;

* Hello world!
public class App
public static void main( String[] args )
ApplicationContext context = new ClassPathXmlApplicationContext(Spring-Module.xml);
HelloWorld obj = (HelloWorld) context.getBean(helloBean);


And Helloworld java as follows.

package com.supun.common;
public class HelloWorld {

private String name;

public void setName(String name){ = name;

public void printHello(){
System.out.println(Hello !+name);

Then create Spring-Module.xml inside the src/main/resources folder as follows.

<beans xmlns:xsi="" xmlns="" xsi:schemalocation="">

 <bean class="com.supun.common.HelloWorld" id="helloBean">
 <property name="name" value="Supun">


Run the application
Here the output


2 thoughts on “Start Spring with Maven & Eclipse

  1. It seems like u actually understand quite a lot
    pertaining to this subject matter and it exhibits
    thru this excellent blog post, given the name “Start Spring with Maven & Eclipse Technodyne”.
    Many thanks ,Eliza

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s