Create Spring web application using Spring Legacy Project in Spring Tool Suite 3

In this tutorial, I will show you the basic steps to create a Spring web application by using Spring Legacy Project in Spring Tool Suite IDE. This is the basic steps which I usually did, you can apply it as a reference.

Create a new project using Spring Legacy Project

I am using Spring Tool Suite IDE version 3.9.9.RELEASE.

To create a new Spring web project, let go to File, choose New and select Spring Legacy Project. A new window will appear as below:

Create Spring web application using Spring Legacy Project in Spring Tool Suite 3

In the Project name field, let enter your project name and in the Templates field, let choose Spring MVC Project as below:

Create Spring web application using Spring Legacy Project in Spring Tool Suite 3

Now, let press Next button.

Spring Tool Suite will download template for Spring MVC Project, so choose Yes button if you see following window:

Create Spring web application using Spring Legacy Project in Spring Tool Suite 3

After downloading, Spring Tool Suite will appear new window.

In this new window, let enter the package name for your project. Example, I enter com.huongdanjava.springmvc.

Create Spring web application using Spring Legacy Project in Spring Tool Suite 3

After that, let press Finish button to Spring Tool Suite create new project for us.

Result:

Create Spring web application using Spring Legacy Project in Spring Tool Suite 3


Revise the project to suit your needs

Expand project nodes to see what we have.

Create Spring web application using Spring Legacy Project in Spring Tool Suite 3

Here, we have a Controller in the package com.huongdanjava.springmvc named HomeController. This controller by default will handle the welcome page when we run the web application. This is not needed for editing yet.

Next, we have a log4j.xml file in the main resource and similarly a log4j.xml file in test resource. This is not needed for editing yet.

Inside the WEB-INF directory of the src/main/webapp/ directory, we have the spring directory containing all Spring configurations. We also do not need to change this.

Also in the src/main/webapp directory, we have a views directory. Inside the views folder, we have the home.jsp file to display the welcome page.

And finally what I want to say here is the Maven pom.xml file. We will need to edit the pom.xml file to upgrade the version of the libraries to the latest. The current version of dependencies is evident in:

The declaration of “java-version” property here, according to me, is not necessary. We should declare the “maven.compiler.source” and “maven.compiler.target” properties so that Maven knows the Java version we need to use for our project with Maven Compiler Plugin. In the plugin declaration section in pom.xml file, the Maven Compliler Plugin plugin is also declared, please upgrade it to the latest version and remove config source and target!

Spring framework is now 5.1.8.RELEASE.

AspectJ and slf4j if you use it in your project, you should upgrade to latest version.

Result:

Create Spring web application using Spring Legacy Project in Spring Tool Suite 3

Chia sẽ bài viết này ...Share on Facebook
Facebook
0Tweet about this on Twitter
Twitter
Share on LinkedIn
Linkedin

Add Comment