From the scratch – Yes really from the scratch!!

  • First let’s download a web container – JBOSS or Apache Tomcat.
    I’ll go for Apache Tomcat as it’s easily available for download.

https://tomcat.apache.org/download-70.cgi

64-bit Windows zip  depending on your OS.

  • Now Lets download the eclipse IDE

http://eclipse.bluemix.net/packages/mars.2/data/eclipse-jee-mars-2-win32-x86_64.zip

 

  • Now let’s create the Spring Project.

You can either create a dynamic web project in eclipse, and add Maven and Spring capabilities.
[or]
Create a Maven project with ‘maven-archetype-webapp’ [An archetype which contains a sample Maven Webapp project.] and then add Spring capabilities.

Let’s look at some basic things before we really get our hands dirty.

Configure Maven [install in ur PC + configure in eclipse]

maven_env_system_variables

Open command prompt and run mvn -version

mvn-version

We forgot to set the JAVA_HOME. Let’s set it.

java_home_environment_var

Now execute the “mvn -version” command

mvn-version_success

Cool!

Since we’re doing the development in Eclipse IDE, Configure the maven and JRE in eclipse as well. [Window – preferences- Maven- installations  and Window – preferences- Java-Installed JREs, compilers]

If you’re creating the dynamic web project , then convert it to to a Maven project, by right click on the project and  Configure-convert to Maven project.

I went by the second way of creating the project, which is better –

  • Create a maven project with with ‘maven-archetype-webapp’ [An archetype which contains a sample Maven Webapp project.] and then add Spring capabilities.

 

 

Now add Spring nature to project. For that first let’s add Spring tools to the eclipse IDE by going to eclipse marketplace [Help – Eclipse marketplace]
eclipse-marketplace-spring

Once installed and eclipse is restarted, Right click on project and click Spring Tools – Add spring project nature.

That’s it.

Now let’s start the real fun :

  • Add the required maven dependencies for a Spring REST project  and develop three REST API’s

Well, don’t write any application without logging, So keep in mind to add the logging dependencies as well.

Eclipse generates a basic version of pom.xml and web.xml for you to build on top of it.

Run your project in the Apache tomcat server [Right click on project and choose run as server].

If you have postman plugin added to chrome [http://www.getpostman.com/] from chrome store, it is beautiful to see the output in your chrome browser after opening the postman app.

Output looks like this:

getAllEmployees

getEmployeeCertifications

 

 

The Complete code is here:

Project Structure in eclipse looks like this:

springrest-structure