Chapter 1.2☕ 16 min read

Setup and Project Structure

A clean project structure is the foundation of maintainable code.

01The Concept: Build Tools & Project Structure

The Hyderabad Software Company Analogy:

Imagine you are running a big IT company in HITEC City.

The JDK (Java Development Kit) is your actual workforce. They write the code and do the real work. Without them, nothing happens.

Maven or Gradle (Build Tools) is your HR and Supply Chain department. You don't have time to go find laptops, desks, and software licenses for every new employee. HR automatically fetches everything they need from a central warehouse (Maven Central Repository) so your employees can just start working.

The Project Structure is your office building layout. The accounting team goes to the 2nd floor, developers on the 3rd floor. If everyone sits randomly, chaos ensues.

02JDK, Maven vs Gradle Explained

1. JDK 17+ — The Non-Negotiable Requirement

Spring Boot 3.x strictly requires Java 17 or higher. You must download and install a JDK (like Oracle JDK or OpenJDK) and set up your JAVA_HOME environment variable.

2. Maven vs Gradle — The Build Tool Battle

Maven: Uses a pom.xml file. It is XML-based, very stable, and the industry standard for 80% of enterprise Java projects.

Gradle: Uses a build.gradle file. It is written in Groovy/Kotlin, much faster for large projects, and heavily used by Android developers.

For this course, we will use Maven because it is the most common in Hyderabad enterprise Java jobs.

03The Standard Project Structure

When you create a Spring Boot project, it generates a very specific folder structure. Here is what your project should look like:

my-spring-boot-app/
├── src/
│ ├── main/
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── devinhyderabad/
│ │ │ └── Application.java <-- Main starting point
│ │ └── resources/
│ │ ├── application.properties <-- Configurations
│ │ ├── static/ <-- CSS, JS, Images
│ │ └── templates/ <-- HTML files
│ └── test/
│ └── java/
│ └── com/
│ └── devinhyderabad/
│ └── ApplicationTests.java <-- Tests
└── pom.xml <-- Maven dependencies
04Best Practices &amp; Rules

Golden Rules for Project Structure

  • Never put Java files in the root directory. Always place them under a base package like com.devinhyderabad.
  • Keep application.properties in src/main/resources. This is where Spring Boot looks for it by default.
  • Use packages to organize your code. As your app grows, create sub-packages like controller, service, repository, model.
05Why It Matters / Interview Note

Interview Question: "What is the difference between Maven and Gradle? Why choose one over the other?"

Answer: Maven is older, uses strict XML configuration, and follows a rigid lifecycle. Gradle is newer, uses a Groovy/Kotlin DSL, and is generally faster because it uses incremental compilation (only recompiles changed files). In enterprise backend Java, Maven is still the dominant choice due to legacy compatibility and strict dependency management, while Gradle is preferred for Android and highly customized builds.

Key Takeaways

  • ✅ Spring Boot 3 requires JDK 17+ — install and set JAVA_HOME
  • ✅ Maven uses pom.xml (XML), Gradle uses build.gradle (Groovy) — Maven dominates enterprise
  • ✅ Standard project structure: src/main/java, src/main/resources, pom.xml
  • ✅ Always place Java files under a base package like com.devinhyderabad