Your first hands-on episode: creating a project with Spring Initializr, understanding the standard directory structure of src/main/java and src/main/resources, running the application with embedded Tomcat and an executable jar, and managing basic configuration in application.properties.

All the theory from the previous two episodes is about to become real. Episode 3 is the starting point of your hands-on practice: creating your first Spring Boot project from scratch, understanding the generated directory structure, running the application in several ways, and creating your first endpoint that actually responds.
Make sure the environment from episode 0 is ready — JDK 21, the Maven wrapper, and internet access to download dependencies. Let's get started!
The easiest way is to open https://start.spring.io, choose the Maven build tool, the Java language, 3.4.x as the Spring Boot version, and Java 21. Add the Spring Web dependency, then click Generate. A ZIP file containing the complete project will be downloaded — extract it and open it in your IDE.
For terminal users, the equivalent can be done with curl to the Spring Initializr starter endpoint. We already tried this in episode 0:
curl https://start.spring.io/starter.tgz \
-d type=maven-project -d language=java \
-d bootVersion=3.4.1 -d javaVersion=21 \
-d groupId=com.example -d artifactId=belajar-spring-boot \
-d name=belajar-spring-boot -d packageName=com.example \
-d dependencies=web,devtools \
| tar -xzvf -
cd belajar-spring-bootThe generated project is ready to open in your favorite IDE. All the curl command lines above can be run repeatedly — the result is that a new project with the same name will overwrite the old folder.
Once the project is created, the standard directory structure looks like this:
belajar-spring-boot/
├── src/main/java/com/example/
│ └── BelajarSpringBootApplication.java
├── src/main/resources/
│ ├── application.properties
│ └── static/
├── src/test/java/com/example/
│ └── BelajarSpringBootApplicationTests.java
├── pom.xml
└── mvnwsrc/main/java: Java source code — home of the main class and all components.src/main/resources: configuration files, templates, and static resources.src/test/java: test code with JUnit 5.pom.xml: dependency definitions and Maven build configuration.mvnw: the Maven wrapper, allowing builds without a globally installed Maven.The main class BelajarSpringBootApplication contains @SpringBootApplication and the main method — this is the application entry point we discussed in episode 2.
Run the application through the Maven wrapper:
./mvnw spring-boot:runThe ./mvnw spring-boot:run command downloads the dependencies, compiles the code, and then starts the embedded Tomcat. Watch for the Started BelajarSpringBootApplication log — at that point the application is serving requests on port 8080.
For production, build the application into a runnable jar:
./mvnw clean package
java -jar target/belajar-spring-boot-0.0.1-SNAPSHOT.jarMaven produces an executable jar — a jar that contains all the dependencies and the embedded web server. This is Spring Boot's advantage: a single artifact can run on any server that has a JVM, without installing Tomcat.
Create a new file in src/main/java/com/example named HelloController.java:
package com.example;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
public class HelloController {
@GetMapping("/hello")
public String hello() {
return "Halo dari Spring Boot!";
}
}The @RestController annotation marks the class as a web controller, and @GetMapping maps the method to HTTP GET requests on the /hello path. The returned body is automatically converted into an HTTP response.
Restart the application (or wait for the auto-restart if spring-boot-devtools is active), then test:
curl http://localhost:8080/helloThe curl http://localhost:8080/hello command should return the text Halo dari Spring Boot!. Congratulations — you just ran your first web application with Spring Boot.
The configuration center is at src/main/resources/application.properties. Its format is key=value. Example of basic configuration:
server.port=8081
spring.application.name=belajar-spring-boot
logging.level.com.example=DEBUG
spring.jackson.default-property-inclusion=non_nullChange the port and run again — the application now serves on port 8081. All Spring Boot configuration follows the module.area.property-name pattern, and the full reference is available in the Spring Boot Reference Documentation.
Besides .properties, Spring Boot supports the YAML format with a tidier hierarchy. The same configuration in YAML:
server:
port: 8081
spring:
application:
name: belajar-spring-boot
logging:
level:
com.example: DEBUGPick one format and be consistent — you must not have both files at the same time because Spring Boot only reads one. We'll discuss the comparison between the two in more depth in episode 8.
Episode 3 completes your practical foundation: creating a project with Spring Initializr via the web or curl, understanding the src/main/java, src/main/resources, and pom.xml structure, running the application with embedded Tomcat via ./mvnw spring-boot:run or an executable jar, creating your first REST endpoint, and managing basic configuration.
Key takeaways:
curl to create it.@SpringBootApplication is the application entry point../mvnw spring-boot:run runs the application with embedded Tomcat on the default port 8080../mvnw clean package produces an executable jar for production.@RestController and @GetMapping create your first REST endpoint.application.properties or application.yml is the center of application configuration.In the next episode, episode 4, we'll discuss dependency injection and bean management — the bean concept, the @Component, @Service, @Repository, and @Controller annotations, constructor vs field injection, singleton and prototype scopes, and lifecycle callbacks. This foundation is used in almost every subsequent episode.