# Getting Started | Building an Application with Spring Boot


Hello Friends, Today we will understand and write our Spring Boot REST API from scratch. We will go through the pre-requisites and later will write the code.

> Tip : If you are new to java, Please visit this [link](https://hashnode.shubhamdeshmukh.com/hello-world-first-java-program) to have better understanding of Java.

---

### The requirement for running our first Spring Boot Application.

For executing any Spring Boot program, the following steps must be followed.

- A favorite text editor or IDE. I will be using Eclipse([Spring Tool Suite (STS)](https://spring.io/guides/gs/sts)) 
- [JDK 1.8](http://www.oracle.com/technetwork/java/javase/downloads/index.html) or later
- [Maven 3.2+](https://maven.apache.org/download.cgi)

---

### Creating Spring Boot Project

Navigate to https://start.spring.io/ in your favorite browser. This is spring intializr which helps us to create a skeleton for our application.

- Add project metadata as you like or you can refer to the screenshot below.
- Choose either Maven and packaging as jar.
- Click Dependencies and select Spring Web.
- Click Generate and a Zip will be downloaded. This will contain all the required files for your project like the main class and pom.xml


![Screenshot 2022-07-03 at 2.11.14 PM.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1657121096837/mvxYmfulr.png align="left")

- unZip the Package and Import the project into IDE.


![Screenshot 2022-07-03 at 2.14.02 PM.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1657121131025/yeXIHPHib.png align="left")

- Once you import give some time to maven to import the required libraries. The project will look like the below once all dependencies are imported. 


![Screenshot 2022-07-03 at 2.16.35 PM.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1657121167708/GznXdilr3.png align="left")

- Now create a package with the name Controller.


![Screenshot 2022-07-03 at 2.18.09 PM.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1657121191030/69NFMX4Pj.png align="left")

- Now that the package is ready we will add a controller to our application. create a new class with the name HelloController.java.


![Screenshot 2022-07-03 at 2.19.20 PM.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1657121214109/DRCCLeBoC.png align="left")

- Add the below code to the class.

```
package com.example.FirstAPI.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HelloController {
@GetMapping("/")
 public String index() {
  return "Greetings from Spring Boot!";
 }
}
```


- Run the application.


![Screenshot 2022-07-03 at 2.23.04 PM.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1657121243549/KQ74zIxE4.png align="left")

Suppose you are not getting the option to run the application as a spring boot application. Run it as a Java Application and give FirstApiApplication.java as an entry point.

- Output Logs


![Screenshot 2022-07-03 at 2.25.37 PM.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1657121266250/yGug9LLGP.png align="left")

Our Application is UP.

---

### Running the API.

Go to the browser and hit http://localhost:8080/ 


![Screenshot 2022-07-03 at 2.28.11 PM.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1657121297939/_J2m9V7yq.png align="left")

---

Thanks for reading. I hope this story was helpful. 

If you are interested, check out [my other articles.](https://hashnode.shubhamdeshmukh.com/)

you can also visit [shubhamdeshmukh.com](http://shubhamdeshmukh.com/blogs).
