Java Spring MVC Application step-by-step in Eclipse using STS

Java Spring MVC Application
Java Spring MVC Application

Are you a Technical Lead or Technical Project manager? Most likely you will work with JIRA to implement Spring MVC Application based solution. Gain more expertise on JIRA by learning top 10 JIRA features.

What is a MVC Framework?

In MVC Framework, MVC stands for Model View and Controller. This is a type of design pattern used in almost all Java web application developed today. It really help to categorize the different layers of Java web application.

So let us understand what does Model, View and Controller means in MVC framework

Model – This layer help to hold the data which can be shared between the next two layers. So we can call this as data carrier which carries data from one layer to another.

View – This layer is solely responsible for the managing the view part for a Java web application. As the name suggest, this layer only take care of views.  In this layer we can use JSP, HTML, CSS, XHTML etc. Also, there are many template engine available which helps us in designing the Java web applications like velocity, freemaker, thyemleaf etc.

Controller – This layer is responsible to take the data from view layer process and send back as response. This is the reason we call this as controller. The controller manages the flow of data between view and model layers.

This is an Architectural Design pattern which is used for enterprise solution. You may also like to learn about design patterns to re-use code level implementations. Learn Top 10 ways to implement singleton design patterns.

What is a Spring Framework?

Spring is a power full framework which now a days is used globally for developing the enterprise based applications. It comes with different flavors like IOC, Web, Jpa, JDBC, Cloud etc. The modern world need such solutions to develop Java web application.

In this tutorials we are going to explore different parts of creating a Spring boot Web MVC application which is going to have a RESTful web service and respond to your request.

To implement spring boot Web MVC application we need following software

  • IDE- Spring tool Suite (STS 3.9.0)
  • JDK – 1.8
  • Maven – 3.5.0

Now let’s learn how to build spring boot Web MVC application step by step.

Step 1: How to Create Workspace in Spring MVC Eclipse?

  • Open the Spring IDE in Eclipse.
  • You will see following Eclipse Launcher screen.

Spring MVC Applicaition - Create Workspace

  • Enter the desired Spring MVC Project workspace name.
  • Click on Launch to create your work space for the Spring MVC

Step 2: How to create Spring MVC project in STS?

  • Download
  • Extract this zip file in a folder.
  • Locate settings.xml file in “apache-maven-3.5.0/Config” folder
  • Refer this file location in Preferences à Maven à User settings. Please refer to the image below.

Create Spring MVC Application Project

  • Once Spring MVC STS Setup is done, it reads your settings.xml and download the dependencies at your mentioned folder.

Step 3: How to Create Spring Web Project?

To create new Spring Web Project:

  • Click on File -> New -> Spring Strater Project

New Spring Starter Project

  • In the new spring starter project, give the desired project name to the new project.
  • Provide the group id for the project
  • Provide Artifact id for the project
  • Write the project description for the project
  • Provide the package name for the project

Packaging – By default in Eclipse, the project packaging is selected as “jar”.

For a web application, we need to change this to “war”.

Click on next to select the dependency of the project.

For a web application, choose the default dependency and again click on next. You will see the following image.

Spring MVC Application - Dependency of the Project

Click finish to create the project from this wizard.

Spring MVC Create a Project

Once project setup is done we will get a project structure like below.

Spring MVC Application - Project Structure

The project, once created, will add maven dependencies by its own. It will also generate a few classes with inbuilt framework. Now you can run this project as Spring MVC application.

SpringTutorialsWebmvcApplication: This class is holding the annotation @SpringBootApplicaiton. This annotation is used  by spring container to know that this is a spring boot application and run this class as main class to load its dependencies and classes to server.

@ComponentScan annotation helps to identify all the spring annotated classes loaded at server startup. A single web application can have multiple packages. The Scan annotation helps to identify the annotated classes to spring container. Hence, all the annotated classes gets loaded to the spring container.

Spring Boot Application

ServletInitializer: This class is used to register your Spring MVC web application in running web or application container.

Step 4: How to customize your Spring MVC application?

Now let’s add a static page for the Spring MVC application inside static folder with name index.html. Please refer to the image below.

Spring MVC application static page

After adding index.html, right click on the spring-tutorials-webmvc project and run as Spring Boot App.

Your application will show you the default landing page like below.

Spring MVC Application Index

The spring boot application is embedded in the tomcat server. Hence, you may execute application directly by clicking right mouse button on the spring-tutorials-webmvc and select “Run As Spring boot app”.

You can deploy this application on any other server. Once the spring mvc application is live, you can access the Spring MVC application at http://localhost:8080.

Your application will show you the default landing page. You can customize the landing page using few tweaks. Let’s try a few things. A server can handle multiple applications at any given time provided we define a project context path with specific port number. We can modify this from Please refer image below.

Spring MVC Application - Application Properties

Apply above configuration and restart application.

Step 5: How to add a Controller?

Add a controller for handling the browser request by adding highlighted section.

Spring MVC Application - Add a controller

In the above example, let’s create a new controller for handling the greetings request.

@RequestMapping – This annotation add request mapping “/rest” to all the request method in this controller class.

@RestController – This annotation make this class work as Rest Controller.

@GetMapping – This annotation make this method behave as get request. The is having url pattern as “/greetings”.

@RequestParam – This annotation make the request parameter of url available to this method. We also assigned default value for the parameter as “World”. If there will be no parameter this default value will be assigned. 

After adding these changes if we run the application and try to access url you will see a page with “Hello World” as shown below.

Spring MVC Application - Hello World

After passing parameter.

Spring MVC Application - Hello Messi

This is the final modification for the Spring MVC application.

I am sure this article will help you boost your Spring boot MVC web application knowledge. And if it did, please share a comment and valuable feedback for me.

Folks, what you would like to read next? Let me know.

Thanks for reading this post on Spring MVC Application.  Please share this post with your friends and help them.

See you soon in the next article.


Is recruiting career a good choice | 7 Reasons to choose Recruiting Career

Recruiting Career
Recruiting Career

A recruiting career could be one of the most fulfilling careers as it directly impacts people’s life. There are a few such other professions e.g. doctors, teachers and farmers. Believe it or not, Recruitment career is another such noble profession that I rate equally. The job journey becomes difficult if the career is not selected wisely.

While doctors save people life and keep them on, recruiters keep making people’s life better. When people struggle to find a new job, recruiters becomes the rescuer. When you look for a better opportunity, it’s the recruiter you turn to. It is the recruiter that brings you that joy of selection for a better job, better pay, and better role.

Check the top ten jobs for 2020 and prepare yourself for future.

Recruiting career is rewarding, joyful, as well as challenging. It is a step by step process that starts from understanding the job description. Once you know what you need to look for, the next step is to find that relevant talent from the pool of resources. Walking the candidate through the interview process is a crucial part of the process. Making the offer and finally on-boarding him closes the recruiting cycle. The entire process leaves you with a feeling of incomparable gratification.

Well, that’s one side of the story. The other better side is that it is one of the most rewarding careers.

Recruiting Career Salary

Working in a profession that is so noble is one thing, but you still need to make money. In the world of economic distress, recruiting career is one of the most rewarding career to choose. The commission are great on every deal. If you get your basics in place, you will start closing the deals and earn incentives. This will lead to hefty pay-checks month over month.

Recruiting is a skill, once acquired, stays with the person forever. The market situation does not impact a recruiter. BFSI not doing well, no worries, Pharma will still be hiring. It’s ok if retail is not hiring, IT will have tons to hire. Every working professional is on a constant lookout keeping the recruiter busy.

This is a career where learning never ends. You continue to learn about new clients, new businesses, and new people. Every new opening opens doors of new learning and a recruiter is always a very informed person. Every new position enables you to meet many new people and help you increase your network. It’s fair to say that a recruiter is one of the most networked professionals in today’s world.

Recruitment Career is a Sales role

Recruiting is no longer a support role. In most of the organizations and especially a staffing firm, it is a revenue generating role. Like any other sales role, this role is also target driven. One of the best parts of this sales is that you don’t have to move out of your desk. The amount of flexibility a recruiting career provides is unimaginable. You can choose your own working hours and your working location.

Communication, negotiation, and networking are a few life skills now. One need all these three skills to become successful. Recruiting is a career that trains you in all these three life skills.

In the last 18 years, I have worked in many organizations. I have created recruiting organization, managed recruiting operations and have trained many recruiters. I have seen them hitting high success scores and achieving success in life.

The feeling

There is a sense of pride when you are instrumental in building somebody’s career. There is a feeling of accomplishment when you networked to a talent pool which is hidden from others. The feeling of individuality when people know you by your name and not the company you represent. There are a lot of other good feelings that recruiting careers helps you experience. Recruiting is like running your small business unit in the organization.

Challenges in Recruiting Career

Of course, nothing comes for free. Recruiting also comes with challenges like deadlines. It is painful to see your candidate clearing all the rounds and still not getting the offer letter. Many a times you feel helpless because there is as much you can do to client processes. But remember, when there is a problem, there is a solution. There are ways to handle such situation. Only those continue to learn and put their learning in place are able to shine.

Want to be an Expert Recruiter?

You could be a fresher or you might be looking forward to elevating your recruiting career to next level. If you have the passion and willingness to make your recruiting career more rewarding, leave a comment and I will bring help your way.


What is your passion and how to find what you love to do

What is your Passion
What is your Passion

“Amit, we will need to cancel our planned outing this Saturday”,

Sonia said in highly depressed tone. And this is not the first time we had to cancel our plans because of an unplanned calling at work on a weekly off. I have seen her going through all this stress in all her corporate, good paying jobs. Do you think it’s just her? Isn’t this your story as well?

And why do you think you are hating the job you are at? You presented your candidature, gave the interview, and picked the job. Remember the day you got the offer letter, perhaps you celebrated the day with your friends. So what went wrong? And is this the first time you are experiencing this dislike to your job or your company?

Dozens of questions but the answer to all this is just one. And the answer to all these questions is in solving just one riddle. What is your passion? Remember, I did not call it a question, I called it a riddle. What is your passion, might look a simple question, if it does, try answering it honestly. You have been picking jobs feeling that working on that job profile is your passion. However, when you picked the job, you asked how much money the job is going to fetch. Instead of asking what you would be doing at work.

Don’t take me wrong when I say that you did not find your passion. Reality is that there is hardly any emphasis on finding your passion at an early age. No body helps a child identify his/her passion let alone nurturing it. You are only taught how to score good marks and find a good job.

So what is your passion?

Like other emotions, passion is a powerful emotion that human being have. This emotion, for something or for somebody, can neither be tamed nor controlled. Everyone is born with a unique swing. A swing that came with you when you were born and stays lifelong. This remains unaltered with external situation of life. Typically, world remembers you because of that swing in you. This is an emotion that is embedded deep in you.

Passion is loosely termed as obsession or craziness. This reminds the famous movie “National Treasure” and the following exerts:

Benjamin Gates: “We don’t really need someone crazy. But one step short of crazy, what do you get?”

Riley (Benjamin’s subordinate): Obsessed

Benjamin: Passionate

Ok, coming back to our vacation plan which just got cancelled. I asked Sonia about what has happened. The story was not different. Work load, manager, not requesting, just ordering to work on scheduled off. My problem was not changing the vacation plan. Nor was I unhappy of that extra work and Saturday working. My problem was long face of Sonia. Her constant struggle of getting up in the morning and getting ready for office. Between 6am to 8am, she used to think of a possibility of the work day being called as a holiday.

It was time to revisit her decisions.

What is your passion and how to find it?

Passion and Success
Passion and Success

We both sat down and I asked her a question. Does she like what she is doing? The answer was a flat “No”.

“I don’t feel like going to office. I don’t like people there. Moreover, I am not enjoying whatever I am doing”, she said painfully.

“If not this, then what do you want to do? What is your passion?” and the answer was “I don’t know”?

The root cause of the problem was in those three words “I don’t know”. Unless we define what we want to really do, we are never going to enjoy it. Correct? More accurately, we need to know what your passion is.

“Passion is one great force that unleashes creativity, because if you’re passionate about something, then you’re more willing to take risks – Yo-Yo Ma”

Finding friends with similar hobbies is difficult let alone the passion. In today’s world you see 10 new startups popping out of somebody’s passion. But almost 98% dies within the first year because the founder failed to build a team of like minded passionate people. Before you do you a startup, you must know the startup failure reasons.

How to find what is your passion?

Fortunately, there is help for you. You can follow a few steps to find what your passion is. You might have several turning points in your life, but finding answer to what is your passion, will be a major one. After we followed the guide on how to find passion, Sonia was able to trace her love. She then knew that she actually likes cooking and more specifically baking.

While we were working on finding Sonia’s passion, we hopped over to Clarity on fire. They have an interesting quiz to take on. At the end of the quiz the website generates your profile report. You will need to enter your name and email id to download the copy, but sure an interesting report to read. You may want to try.

Today, Sonia spends most of her weekends conducting healthy baking workshops. Ironically, today she is happy working on a weekend. She spends her weekdays creating new recipes and evenings in drafting them and sometimes working till midnight.

The difference today is that she works for herself. She works on what she loves. Today, there are no more stressful evenings, no more painful workloads. Finally, she found her passion and made it her career. Today she is famous and run her successful venture called Sonlicious.

This is what we aim to achieve with everyone on Mapped Skills. We help people know what their true passion is and then break passion into monetize-able skills. We help you monetize your skills and start building passive recurring income.

Come join the mission.


Recent Posts