Spring Boot Maven Example Hello World with JSP

Spring Boot Maven Example Hello World walks you through the process of creating a example spring boot step by step. Spring Boot is sub-project developed by developers of spring framework, Spring Boot makes it easy to create stand-alone, production-grade Spring based applications with minimum configuration possible.

Other interesting posts you may like

Let’s begin:

Project structure
We will create a project with directory structure like below

Spring Boot Maven Example Hello World

Maven Dependencies
To create Spring Boot Maven Example Hello World, you need to add dependencies into pom.xml file like below:

Let’s dig deeper:

We are developing a web application so we will add a spring-boot-starter-web dependency in pom.xml like below:

Our application needs to use the Tomcat libraries at runtime, the we should append the below dependency in pom.xml file and set scope of the dependency to provided.

In order to enable JSP support using Tomcat we need to add dependencies into pom.xml like below:

In this example, we are using maven plugin so we need to add the below dependency into pom.xml file:

Configure Spring Web Application
To set our application up as a servlet application we extend our main class with SpringBootServletInitializer and override the configure method using SpringApplicationBuilder.

Configure properties file

Create the Controller
We create a simple controller named HelloWorldController like below.

If you have any issues with creating Spring controller you can see detail the tutorial Spring MVC Tutorial Step by Step for Beginners.

Create the View

We create a view using jsp page to display “Hello World” words and other message.

Run Application
To deploy and run our Spring Boot Maven Example Hello World on web container, we run the below command in console

Note: You must be in your project directory before run that command.

While running that command, you will see the output like below

Spring Boot Maven Example Hello World

After running successfully, you can access the application via URL http://localhost:8080 and see the homepage such as

Spring Boot Maven Example Hello World

Click the link “Click me to say Hello” then the Hello World page is displayed

Spring Boot Maven Example Hello World

That’s it on the tutorial Spring Boot Maven Example Hello World with JSP.

Download complete source code, please click link below

SpringBootMavenExampleHelloWorld.zip (59 downloads)

Source code on Github https://github.com/javabycode/spring-boot-maven-example-helloworld

Leave a Comment

*

Please share it if you found this useful
Hide Buttons