Spring Boot project setup with Spring Initializr
Introduction
start.spring.io (Spring Initializr) is the official way to bootstrap a new Boot project. You select build tool, language, Java version, Spring Boot version, and dependencies (Web, Data JPA, PostgreSQL, etc.), then download a zip or use your IDE. This post gives a repeatable flow we use for the rest of the series.
Real-world explanation
In teams, the same Initializr choices (or a company template derived from it) make onboarding predictable. You are not hand-copying 50 dependency blocks from random blog posts. The parent spring-boot-starter-parent in the generated pom applies sensible defaults: compiler plugin, JUnit, dependency versions. You add business code.
Step-by-step (browser)
- Open https://start.spring.io
- Project: Maven (or Gradle if you prefer, see article 3)
- Language: Java
- Spring Boot: pick a current stable 3.2+ (match your team)
- Group:
com.example, Artifact:demo-service(change to your domain later) - Packaging: JAR, Java: 17 or 21
- Dependencies (Add):
- Spring Web — REST, embedded Tomcat
- Spring Data JPA — Hibernate + JPA
- PostgreSQL Driver
- Lombok (optional, nice for entities/DTOs)
- Validation —
spring-boot-starter-validation - Spring Boot DevTools (optional) — restarts in dev
- Generate → unzip into your workspace
- Import as Maven project in IntelliJ / Eclipse / VS Code
Run the first time (Maven)
cd demo-service
./mvnw -DskipTests package
java -jar target/demo-service-0.0.1-SNAPSHOT.jarOr during development:
./mvnw spring-boot:runDefault Application.java
package com.example.demoservice;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}Folder structure you should see
src/main/java/com/example/demoservice/
Application.java
src/main/resources/
application.properties (or empty; we switch to yml in article 6)
src/test/java/
pom.xml
mvnw / mvnw.cmdCommon mistakes
- Choosing WAR here when you are learning JAR deployment; leave JAR until you have a real constraint.
- Java 8 on the machine with Java 17 in the POM: align IDE project SDK and
JAVA_HOME. - Forgetting to unzip into a folder with no spaces in path (some tools are picky on Windows).
Best practices
- Commit
mvnwand.mvn/wrapperso every teammate uses the same Maven (wrapper is generated by Initializr). - Keep the default package as
com.yourorg.project, not a singledefaultpackage.
Final summary
Initializr gives a runnable Boot skeleton with a correct parent and entries for the stack you check. We add structure (entity, repository, service, controller) in the next articles, then yml configuration and PostgreSQL.