Spring Boot Learning-Part 2

Hardik
3 min readApr 29, 2021

In This session we will learn Environment setup, Build your 1st spring boot application, Understand project structure and entry point of spring boot application.

Hello Friend If you have not gone through my previous session, then below are the reference.

Part-1 Spring Boot Fundamental

Now let’s get started

Environment Setup

  1. Download JDK and setup environment variable in your system.
  2. To build a spring boot application, I would suggest below IDE. You can use any one of them.

Create your First spring-boot application.

The easiest way to build your 1st spring-boot application is using a Spring Initializr.

Spring Initializr : Used to create a template project for spring-boot application.

Spring Initializr
Spring Initializr

To create a template project open https://start.spring.io/ website and add details as above screenshot.

  1. Select build type (Maven or Gradle. I am going with Maven)
  2. Select language for your spring-boot application (Java or Kotlin)
  3. Select Spring-boot version (I would recommended to select stable one)
  4. Insert your project description.
  5. Add Spring Web dependency.(Because I don’t want to deploy application my self, It should auto deploy to Tomcat 😅)

Click on GENERATE button. Which will generate zip template project. You need to unzip that project and import it into your IDE.

Understand Project structure

  1. src/main/java : Will contain your backend code.
  2. src/main/resources/static: You can add your static frontend code here
  3. src/main/application.properties: Will contain your application configuration(IP, Port, Database config etc.…)
  4. src/test: Contain unit-test cases of your application.
  5. pom.xml: Contain your dependencies, application version, application description, JDK version etc.

Entry Point

Application Class

As we all know in JAVA, main(String[] args) method is entry point. Same theory is applicable in case on spring-boot application. JVM will execute main method and from main method spring boot application will run by executing

SpringApplication.run(<Application class>,<main method argument>)

Here you can also notice new annotation @SpringBootApplication This annotation intimate JVM that this is spring-boot application, So that auto configuration will be apply. This annotation will also initiate JVM to scan component like Rest Controller, Repository, Service class etc.

Spring Boot Learning Series

  1. Fundamental of Spring Boot

--

--