Spring Boot v.2.0.2 Release Hello World Example

Spring Boot v.2.0.2 Hello World Example.


This is our first simple Spring Boot Hello World example. I am using these following ingredients to build and run this simple Spring Boot Web Application.
  • Intellij Idea 14.1.7
  • jdk 1.8.0_162
  • Gradle 4.6
You can use Maven as build tool but I prefer Gradle. So Let's start it. Create a new project using Intellij.

Create New Project

We create our Project by using Spring Initializr. At this point you can configure Project SDK, here we use 1.8 as shown below.

Create New Project using Spring Inializr

After clicked on next button, Now setting the Project's basic configuration as show below.

Project Basic Settings

Now at next screen first select Spring Boot Version (we are using 2.0.2) and also select Spring boot Starter Web Freamwork and Thymeleafe as Templating Engine.

Spring Boot Setting
  Now named your Spring Boot Project and set its location.

Setting Spring Boot Project Name and Location

After finish the wizard, you need to import your Spring Boot Project as Gradle Project. The ballon or tool tip will appear in Intellij as show below.

Import Your Spring Boot Project as Gradle Project
Lets take a look on import settings. You should marked on auto-import and create directories for empty content roots automatically. You can use default gradle wrraper but here we use our local gradle distribution.

Gradle Import Settings

After download all the project dependencies, here we have our Spring Boot Project Structure. Now Intellij does not recognize source, resources and test directories so you can mark it manually.

Mark Source, Resources and Test Directories

Now the last step is include a view in our Spring Boot Project. Create a HTLM page in src/main/resources/templates/index.html 

Create a View (html page) in our project

Now at this stage our First Simple Spring Boot Project is ready to run. Spring Boot have Emebedded Tomcat Server so we don't need to configure any External Server or Servlet Engine.
Now just double click on gradle's bootRun task and the Spring Boot Majic begins.

BootRun
It takes few seconds to Initialize Spring Boot and starting embedded tomcat server. 

Spring Boot Web App Starts on port 8080.

Now we can access our Spring Boot Web Application on http://localhost:8080/ 

Accessing Spring Boot Web App at http://localhost:8080/

 By default embedded tomcat start on port 8080. If port 8080 already captured by another application so you can configure it in application.properties file as server.port = 8090.

Comments

Popular posts from this blog

How To Run Spring Boot Web Application On External Tomcat

Basic CRUD Application Using Spring Boot REST Web Service with AngularJS