Create your first Spring Boot Application

Janith Senanayaka
3 min readJun 4, 2021

01) what is Spring Boot?

Spring Boot is a Java based framework that is an open source used to create a micro service. It was developed by the Pivotal Team and is used to create standalone and product-ready spring applications.

02)what is Micro Service?

Micro Service is an architecture that allows developers to independently develop and deploy services. Each service operates on its own, and this takes a lightweight form to support business applications.

03)Why Spring Boot?

  • It provides a flexible way to configure Java Beans, XML configurations, and Database Transactions.
  • It provides a powerful batch processing and manages REST endpoints.
  • In Spring Boot, everything is auto configured; no manual configurations are needed.
  • It offers annotation-based spring application.
  • Eases dependency management.
  • It includes Embedded Servlet Container.

04)How to create simple Spring Boot project?

Requirements

· Java 1.8 or 11

· Maven 3.2+

· use your favorite Java IDE (Eclipse ,Spring tool Suite, intellij) and i’m using intellij for this

I use Spring Initializr to generate my spring boot project with the required dependencies.

By default everything is selected when you visit the link above. You can select the type of project (Maven). In the Add-ons section, you can select the spring boot app version you want to create. Here, I have chosen spring web as dependency.
So after you make the necessary changes, click Generate to download your Spring Boot Project. After downloading the project, open it in your favorite IDE and give the time to resolving project dependencies.

After successfully opening the project, you will see a folder structure similar to the image above ( intellij IDE)

you can see the project dependencies inside the pom.xml file

Example -: web server base “hello world”

Then create a class in the package and write the code according to the image above.

@RestController annotation is used to imply that this application is to use by Spring MVC to handle web requests. @RequestMapping maps the method to the specified path in the URL.

Then go to the Demo application class and run project according to the image above.

If there is a port error during runtime please go to the application properties file and put a different port like (server.port=9393)

Then go to the web browser and type url = http://localhost:9393/

lest check in the browser

Congratulations!!! You have successfully created your first application using java Spring Boot.

--

--