Spring Boot Basics For Day 1 Leaners
I'm Saroj Bist, a self-taught web developer, learning and building with the MERN stack. I started with front-end tools like ReactJS and Tailwind CSS, and slowly stepped into full-stack development, working on real projects and solving real problems. This blog is where I share what I’m learning — from small bugs to full project insights — in a way that helps both me and anyone on a similar path.
1. Creating a Spring Boot Project
Created a Spring Boot project using Spring Initializr.
Configuration:
Project: Maven
Language: Java
Spring Boot: 4.1.0
Group:
com.testArtifact:
demoPackage:
com.test.demoJava: 21
Dependency: Spring Web
Generated project structure:
src
├── main
│ ├── java
│ │ └── com.test.demo
│ │ └── DemoApplication.java
│ └── resources
│ └── application.properties
└── test
2. Running the Application
Start the application:
./mvnw spring-boot:run
If successful, Spring Boot starts an embedded web server.
Default URL:
http://localhost:8080
3. Basic Java Object Creation
Class:
public class TestClass {
public String test() {
return "Test";
}
}
Creating an object and calling a method:
String value = new TestClass().test();
System.out.println(value);
Output:
Test
4. Printing to Console
Inside main():
System.out.println("hello");
Output:
hello
5. Creating a Simple REST Endpoint
Controller:
@RestController
public class TestClass {
@RequestMapping("/")
public String test() {
return "Test";
}
}
Access:
http://localhost:8080/
Response:
Test
6. What @RestController Does
@RestController
Marks a class as a web controller.
Methods inside it can handle HTTP requests and return responses.
Example:
@RequestMapping("/")
public String test() {
return "Test";
}
When a browser visits /, this method executes.
7. Understanding the Root Path
@RequestMapping("/")
/ means the root URL.
Examples:
/ -> homepage
/users -> users endpoint
/products -> products endpoint
Example:
@RequestMapping("/hello")
public String hello() {
return "Hello";
}
URL:
http://localhost:8080/hello
8. application.properties
Location:
src/main/resources/application.properties
Used for application configuration.
Example:
server.port=9090
Now the application runs on:
http://localhost:9090
instead of:
http://localhost:8080
9. Important Files
DemoApplication.java
Application entry point.
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
application.properties
Stores application configuration.
pom.xml
Stores project dependencies and build configuration.
10. Commands Learned
Run application:
./mvnw spring-boot:run
Build project:
./mvnw clean package
Run tests:
./mvnw test
Summary
Learned:
Create a Spring Boot project
Run a Spring Boot application
Create Java objects using
newCall methods on objects
Print output using
System.out.println()Create a basic REST endpoint
Use
@RestControllerUse
@RequestMappingAccess endpoints from the browser
Change server port using
application.propertiesUnderstand basic project structure



