Create a new Spring MVC project using huongdanjava-spring-mvc-archetype

Nowadays, in web applications using the Spring Framework, we often use Spring Boot to build these applications. Essentially, Spring Boot also uses Spring MVC but provides additional mechanisms such as auto-configuration, dependency management, embedded servers, and production features, making the application development process much simpler. To understand what our application does behind the scenes and to customize the default Spring Boot configurations, you need to learn about Spring MVC to understand how it works.

In this tutorial, I will guide you on how to create a new Spring MVC project using my huongdanjava-springmvc-archetype, so you can learn how Spring MVC works!

This Maven archetype is created from a Spring MVC template that I mentioned in this tutorial. The drawback of using this Spring MVC template is that you have to use Spring Tool Suite 3, even though Spring Tool Suite 4 has been released for a long time. You also can’t use it with other IDEs. Furthermore, after creating the project, you have to update and modify dependencies, and then add the Maven Jetty Plugin to run the application.

Seeing these shortcomings, I created this new Maven Archetype and published it to the Central Maven Repository so you can easily create a new Spring MVC application and use it without much effort.

Now, if you are using Eclipse or Spring Tool Suite to create a new Spring MVC project using Maven:

then, in the Eclipse “Select an Archetype” window, you can filter and select huongdanjava-springmvc-archetype project as follows:

Click Next to fill in the project information:

Click Finish to create a new project.

The result will be as follows:

My Maven Archetype project already includes the Maven Jetty Plugin, so you just need to run it.

The result is as follows:

If you are using IntelliJ IDE, in the project creation window, use Maven Archetype and select huongdanjava-spring-mvc-archetype.

The versions of huongdanjava-spring-mvc-archetype are as follows:

Version

Spring MVC version

Jetty version

3.0.0

7.0.9

11.0.26

2.1.2

6.1.9

11.0.21

2.1.1

6.0.9

11.0.15

2.1.0

6.0.7

11.0.14

2.0.0

6.x

11.x

1.0.0

5.x

9.x

Currently, the Maven Archetype supports Spring MVC 7.x with the latest Jetty version being 11.x.

Depending on your needs, you can modify the generated project to suit your requirements!

Add Comment