Spring Boot simplifies the process of building production-ready applications with the Spring Framework. In this guide, we’ll walk through creating your first Spring Boot application step by step.
Written by
Şuayb Şimşek
Backend-focused fullstack developer sharing practical notes on Spring Boot, security, microservices, and cloud-native architecture.
🔄 Spring Boot Version: 3.0.0 (or the latest version).
📜 Add dependencies: Spring Web
Click Generate to download the project files.
Using IntelliJ IDEA 💻
Open IntelliJ IDEA.
Go to New Project > Spring Initializr.
Configure similar parameters as mentioned above.
🛠️ Step 2: Writing Your First Endpoint
Let’s write a simple endpoint to say hello:
▶️ Step 3: Run the Application
In this section, we clarify Step 3: Run the Application and summarize the key points you will apply in implementation.
Open a terminal in the project folder.
Execute the command to run your application:
BASH
./mvnw spring-boot:run
Access the endpoint at:
FILENAME
http://localhost:8080/hello
Response:
FILENAME
Hello, Spring Boot!
🏁 Conclusion
You now have a practical Spring Boot - First Application implementation with a clear, production-friendly Spring Boot structure. As a next step, adapt configuration and tests to your own domain, then validate behavior under realistic traffic and failure scenarios.
JAVADemoApplication.java
package com.example.demo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@SpringBootApplication
@RestController
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
@GetMapping("/hello")
public String sayHello() {
return "Hello, Spring Boot!";
}
}
KOTLINDemoApplication.kt
package com.example.demo
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RestController
@SpringBootApplication
@RestController
class DemoApplication
fun main(args: Array<String>) {
runApplication<DemoApplication>(*args)
}
@GetMapping("/hello")
fun sayHello(): String {
return "Hello, Spring Boot!"
}