Spring-Boot Starter Project

Rahul Kumar
3 min readJun 16, 2021

## Steps to create a basic spring boot project using maven as a build tool without any database.

  1. Go to https://start.spring.io/

Fill the fields as shown in the screenshot and click on the GENERATE button to download the project's zip file.

*** Remember to choose the spring web dependency. ***

2. Unzip the folder and open the file in any on the IDE. It might take some time for the first time to load the project, as it downloads dependency from a cloud-based central repository.

  • This repository is a central place from where you can get all the required dependencies for your project.

3. Once the IDE is ready, go to `appilcation.properties` file and add the below line.

  • server.port = 8080
  • You can choose to write any port. This will be the port where the application can be accessed.

## That’s pretty much all you need to create a basic project without any database connection. Now it’s time to test.

  • To run the application, go to the folder where the pom.xml file is present and execute `mvn spring-boot: run` command to build the application.
  • once the application started, open any browser and open localhost:8080 to access the application.

Wait what..! you got error.. ??

Don’t worry…!! Since there is no view resolver till now, that’s why the error is coming. Let’s write some code to resolve this error.

## Create a package named controller and create a file inside it named UserController inside it and put @RequestController annotation on the class and create a GetMapping method in it. The final code should look like this:

package com.spring.tutorial.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UserController {


@GetMapping("/congrats")
public String printCongratsMessage(){
return "Congrats..!! Your error is resolved now.";
}
}

# Now run the code using mvn spring-boot:run command and hit http://localhost:8080/congrats to see the message in the browser.

Congrats..!! Your basic set is done.

…………….….….*******************************…………………...

Things to learn before we move to the next steps:

  • @RestController Vs @Controller.
  • @Autowire, @Service, @Repository.
  • Dependency Injection and IOC (only definition).
  • HTTP status codes.
  • CRUD operations in Spring Boot.

— — — — — — — — — — — — -NEXT STEPS— — — — — — — — — — — —

# Now let’s learn more, create some more methods, services, repositories and connect the application with an in-memory database (H2 DataBase).

--

--