Spring Boot + PostgreSQL + AIPart 4

Spring Boot project setup with Spring Initializr

Step by step: create a Spring Boot project on start.spring.io (or the IDE), choose the right options for REST and PostgreSQL, and run it the first time.

Author: Sushil Kumar

Spring InitializrSpring Boot

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)

  1. Open https://start.spring.io
  2. Project: Maven (or Gradle if you prefer, see article 3)
  3. Language: Java
  4. Spring Boot: pick a current stable 3.2+ (match your team)
  5. Group: com.example, Artifact: demo-service (change to your domain later)
  6. Packaging: JAR, Java: 17 or 21
  7. Dependencies (Add):
    • Spring Web — REST, embedded Tomcat
    • Spring Data JPA — Hibernate + JPA
    • PostgreSQL Driver
    • Lombok (optional, nice for entities/DTOs)
    • Validationspring-boot-starter-validation
    • Spring Boot DevTools (optional) — restarts in dev
  8. Generate → unzip into your workspace
  9. 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.jar

Or during development:

./mvnw spring-boot:run

Default 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.cmd

Common 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 mvnw and .mvn/wrapper so every teammate uses the same Maven (wrapper is generated by Initializr).
  • Keep the default package as com.yourorg.project, not a single default package.

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.