Spring Boot MVC Web Application Tutorial using Thymeleaf & Bootstrap

Share this

Let’s Kick-start a simple Spring Boot MVC web application with Thymeleaf as template engine, powered by Bootstrap UI. It will have Data layer as JPA which can support Hibernate/HSQLDB/Spring Data JPA and Mongo DB in the backend. It will also use Spring Security for the login and logout functionality.

Get started

We will not reinvent the wheel! Head towards this Spring MVC Quickstart Maven Archetype github project. This project is a Maven archetype for Spring MVC web application. A big Thanks and shout out to Rafal Borowiec, the creator of this GitHub project.

Step 1

Download the archetype zip or you can clone the repository, as you like to do.

Step 2

Extract it in a folder and open command window to run the following command. It will install the said archetype in your local machine.

mvn clean install

Step 3

Once step 2 has run successfully, run the following command to create the sample Spring Boot MVC web application, maven project.

mvn archetype:generate -DarchetypeGroupId=pl.codeleak -DarchetypeArtifactId=spring-mvc-quickstart -DarchetypeVersion=5.0.1 -DgroupId=my.groupid -DartifactId=my-artifactId -Dversion=version-1.0 -DarchetypeRepository=http://kolorobot.github.io/spring-mvc-quickstart-archetype

To know how the mvn archetype:generate works, check the documentation on apache maven project website.

Once you run the command, you will notice that it tries to create a maven project with the given runtime parameters. Just press Y and it will create a maven project named my-artifactId.

Installation Done. What next?

Once you have run the above command, go inside the my-artifactId folder and run following command –

mvn test tomcat7:run

The above logs means that it has successfully initialized the Spring Boot MVC Web Application. Now, open a browser and hit the URL – http://localhost:8080 to view the beautiful web application backed by the bootstrap UI.

This tutorial is to quickly start a Spring Boot MVC Web Application with a boilerplate code. Looking up on internet for such boilerplate code, this is the best you can get. Please let us know in the comments section if you find any other interesting Spring Boot MVC Web Application boilerplate code. We will be happy to test them out.

Now, You may just like to play around with this localhost application like signup, login and logout features to understand its behavior. At first it may look like very limited and simple for a web application but it is the most important and simple basic feature to start with, on top of which you can just start building your functionality.

That’s all for today, we will dive deeper to the generated maven project code base in another blog and we will also share some of sample code on WebFuse GitHub. Stay tuned by subscribing to our newsletter.

Feel free to drop in your questions/concerns in the comments section below if you face any problem in carrying out the above steps while following this tutorial. We will be more than happy to help!!

Share this

Leave a comment

Your email address will not be published. Required fields are marked *

2 thoughts on “Spring Boot MVC Web Application Tutorial using Thymeleaf & Bootstrap”