Spring boot Hello world

Spring Tool Suite(STS) makes it easy to develop spring boot applications.We will create a simple HelloWorld application using spring boot.

Tools used to create below project – 

  1. Spring Boot 2.0.2.RELEASE
  2. Spring 5.0.6.RELEASE
  3. Tomcat Embed 8
  4. Maven 3.3
  5. Java 8
  6. Spring Tool Suite IDE (STS)

Github Link :   Download

Step 1: Go to File -> New -> Spring Starter Project . Then you need to configure project name, group, artifact and package as shown below –

Step 2: Configure maven dependencies

You just need to select dependencies and STS will automatically pull these dependencies for you . Please refer below screenshot –

For this project we just need web dependency. Below pom.xml generated after clicking on finish. Additionally add tomcat-embed-jasper and JSTL dependencies to it.

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">


<description>Demo project for Spring Boot</description>

<relativePath/> <!-- lookup parent from repository -->




<!-- JSTL for JSP -->

<!-- For JSP compilation -->




Below project structure will be created for you by STS.


package com.myjavablog;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

public class SpringBootHelloWorldApplication {

public static void main(String[] args) {
SpringApplication.run(SpringBootHelloWorldApplication.class, args);

This is the main file which bootstraps the spring application. This is generated by STS for us.

Step 4: Create a controller class


package com.myjavablog.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

public class HelloWorldController {

@RequestMapping(value="/", method=RequestMethod.GET)
public String getHomePage() {

return "index";

<strong>Step 5:</strong> Create index.jsp


<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%>

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Hello World</title>
<body >
<h4>Hello World!!!</h4>


Step 6: Clean and install project

Now run the maven clean install phase as below –

Command:  mvn clean install


Right click on project -> Debug As -> Maven build . Below popup will come up –

Enter clean install and click on debug. After successful build, it will create below artifacts in target folder –

Step 7: Run the spring application

Command:  mvn spring-boot:run


Right click on project -> Debug As -> Spring boot App

Now spring boot will internally host the application on embeded tomcat server . You can access your application through below url –


Note: You can configure details like port number, view files location , database properties in file present inside /src/main/resources/application.properties file.

Ex. – application.properties

spring.mvc.view.prefix: /WEB-INF/views/
spring.mvc.view.suffix: .jsp

Leave a Comment