Search Tutorials

Spring Boot Hello World Application- Create simple controller and jsp view using Gradle | JavaInUse

Spring Boot Tutorial-Spring Boot+ Gradle

In this post we create a Hello World Spring Boot Application using Gradle build tool.


This tutorial is explained in the below Youtube Video.

Lets Begin-

If Gradle plugin has not been installed for your eclipse, go to Help->Eclipse Marketplace. Search gradle and install the Buildship Gradle Integration 1.0. This will install the gradle plugin

Now go to File->New->select Gradle Project. Name it as spring-boot-gradle.


The gradle project we will be creating is as follows

Along with the Spring Boot dependencies we have also tomcat-embed-jasper and jstl jar dependencies as these are required when jsp view is used. Modify the build.gradle as follows-
buildscript {
	ext {
		springBootVersion = '1.4.3.RELEASE'
	repositories {
	dependencies {

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'

jar {
	baseName = 'boot-gradle'
	version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8
targetCompatibility = 1.8

repositories {

dependencies {

Create the as below-
package com.javainuse;

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

public class BootGradleApplication {

	public static void main(String[] args) {, args);

@RequestMapping maps /welcome.html request to firstPage() method.
package com.javainuse;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

public class TestController {

	public ModelAndView firstPage() {
		return new ModelAndView("welcome");


In the we define the prefix and suffix as follows. So in the above controller the /welcome.html correctly maps to /WEB-INF/jsp/welcome.jsp.
Last we define the welcome.jsp as below-
<h1>Welcome to Spring Boot</h1>

Compile and the run the as a Java application.
Go to localhost:8080/welcome.html

Download Source Code

Download it -
Spring Boot Hello World using Gradle

See Also

Spring Boot Hello World Application- Create simple controller and jsp view using Maven Spring Boot Tutorial-Spring Data JPA Spring Boot + Simple Security Configuration Pagination using Spring Boot Simple Example Spring Boot + ActiveMQ Hello world Example Spring Boot + Swagger Example Hello World Example Spring Boot + Swagger- Understanding the various Swagger Annotations Spring Boot Main Menu Spring Boot Interview Questions