Skip to main content

Spring Initializr

Head to Spring Initializr, the official Spring Boot project generator (honorable mention to Bootify, interesting alternative).

You'll see a form. Don't panic, we'll decode each option.

Start Spring Io 9c5d89cc01b14b24ca16de52e347f413

Project: Maven vs Gradle

Scroll to zoom • Drag corner to resize

If you're looking for a "path of least resistance," here's how the pragmatics usually shake out:

  • For Java projects: Most developers gravitate toward Gradle Groovy. Since it's the default on Spring Initializr, it has become the industry standard.
  • For Groovy projects: Use Gradle Groovy. Keeping your build logic and your application logic in the same language saves you from the mental context-switching tax.
  • For Kotlin projects: Go with Gradle Kotlin. Again, it's all about language synergy. If you're already writing Kotlin, you might as well enjoy the type-safety and IDE autocomplete in your build scripts too.

The reality? There is no "wrong" combination.

Spring Boot Versions

When selecting a Spring Boot version, you'll encounter three types of labels:

  • SNAPSHOT
    • Indicates a development build of Spring Boot.
    • These versions are unstable, actively being worked on, and may include untested features or bugs.
    • Avoid using them for production, as they can change without notice.
  • M1, M2, etc. (Milestones)
    • Pre-release versions mark major milestones (e.g., new features) before a stable release.
    • More stable than SNAPSHOT but still not production-ready. Ideal for early testing of upcoming features.
  • No Marker (Stable Releases)
    • These are stable releases, rigorously tested and production-ready.

Always opt for the highest stable version (without SNAPSHOT/M labels) unless you explicitly need experimental features.

Project Metadata

The Project Metadata section defines your project's identity and structure. Here's a breakdown of each field and its recommended conventions:

FieldWhat It MeansRecommended Structure/StandardExample
GroupIdentifies your organization/teamUse reverse domain name notation. Avoid generic termscom.acme
ArtifactThe project's nameUse lowercase letters and hyphens for multi-word namesinventory-service
NameHuman-readable display nameUse spaces/capitalization for readabilityInventory Management
DescriptionBrief summary of the project's purpose. Added to pom.xml/build.gradleKeep concise (1–2 sentences) and specificMicroservice for tracking warehouse inventory
Package NameRoot Java package for source codeDerived from Group + Artifact (hyphens removed)com.acme.inventoryservice

Personal preference: I like to use underscores (_) in the artifact name. There's no rule against it, but I find it helps to keep consistency, because Spring Initializr will replace the hyphen with underscore in some folders.

Packaging: JAR vs WAR

Packaging determines how your application is bundled into a single, shareable file, enabling it to run smoothly on any system without complex setup.

FormatBest ForKey Difference
JARModern Spring Boot apps, microservices, cloud deploymentsContains embedded server (e.g., Tomcat) for self-contained execution
WARLegacy apps or deployments to external servers (e.g., traditional Tomcat, JBoss)Requires a separate server to run; no embedded server included

Use JAR unless you're bound to legacy infrastructure. JAR is the default in Spring Boot. Spring Boot's embedded server makes JAR the lightweight, hassle-free choice for most projects today.

Configuration: Properties vs YAML

You're typically going to run into two main formats in Spring Boot: application.properties and application.yml (or application.yaml). Both do the same job, and they let you define key-value pairs to configure your application, database connections, server ports, and all that fun stuff.

application.properties
server.port=8080
spring.datasource.url=jdbc:h2:mem:testdb
spring.datasource.username=sa
spring.datasource.password=

The "Classic" Choice:

  • It's simple, straightforward, and has been around forever.
  • Each property is on its own line: key=value.
  • Great for small configs, but can get messy with nested properties. Think of it like a long shopping list where every item is just listed one after another.

My personal preference is YAML. Why? Because I find it significantly easier to read and organize, especially as configurations grow. Plus, most modern tools and APIs often lean into YAML for configuration these days.

Ultimately, both work perfectly fine. If your team has a standard, stick to it. If you're starting fresh, give YAML a shot.

Java Version

  • Stick with what your team uses.
    • If your team is using an old unsupported version, go for the lowest version Spring Initializr provides.
  • If unsure, pick the latest LTS. It's the sweet spot.

I'm picking Java 21 because 25 was giving me problems with Kotlin build.gradle.kts

Dependencies

Dependencies are pre-built libraries that add specific features to your app (like tools in a toolbox). For now, we'll use the ones you'll need in 90% of real-world Spring projects:

DependencyCategoryWhy You Need It
Lombok (Only for Java projects)Developer ToolsReduces repetitive code (e.g., getters/setters) with simple annotations
Spring Boot ActuatorOperations/MonitoringAdds health checks, metrics, and management endpoints for your app
Spring Boot DevToolsDeveloper ToolsSpeeds up development with auto-restarts, LiveReload, and debug-friendly config
Spring Configuration ProcessorDeveloper ToolsEnables code-completion for custom application.properties/yml settings
Spring WebWebBuild REST APIs with Spring MVC + embedded Tomcat server

Generate

Once you've configured your Spring Boot app, hit the Generate button (or Ctrl + Enter). Spring Initializr will bundle your project into a .zip file.

In the screenshots below, we're creating the Demo project that we will develop during the rest of this guide, using different languages for demonstration.

Start Spring Io Java 9bde37bc9de54aea48df02682ef738d1
info

You don't need to download all three language versions for this guide. Pick the language you prefer and stick with it. If you're feeling adventurous and want to explore all three, you can clone the monorepo we've prepared at https://github.com/franBec/springboot-demo-projects.

What's inside the zip?

  • A standard project structure (folders for code, tests, configs).
  • Preconfigured pom.xml (Maven) or build.gradle (Gradle).
  • A starter application.yml file.
  • The main class (*Application.java) to run your app.

Don't worry about the details yet. We'll unpack and explore everything together in the next steps.