Chapter 1.7☕ 16 min read

POM.XML and Configuration

Understanding pom.xml is understanding Spring Boot itself.

01The Concept: Starters & Configuration

The Tiffin Box Analogy:

If you want to eat lunch at your desk in an IT park, you don't go to the store and buy rice separately, dal separately, and curry separately. You order a Tiffin Box. The vendor has already curated the perfect combination of items into one box.

In Spring Boot, Starters are Tiffin Boxes. If you want to build a web API, you don't hunt for Tomcat, Jackson (for JSON), and Spring MVC jars separately. You just ask for spring-boot-starter-web, and Spring Boot puts all of them into your project.

For Configuration (application.properties), imagine you're the Tiffin center manager. You need a single place to write rules: "Make the food spicy," "Deliver to Tower 2," "Use disposable plates." application.properties is that rulebook.

02The pom.xml Breakdown

Every Spring Boot project needs a pom.xml file. Here's the exact breakdown of what makes it work:

<!-- 1. Parent POM: Handles dependency versions and plugin config -->
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.2.0</version>
<relativePath/>
</parent>

<dependencies>
<!-- 2. Starter Web: Brings Tomcat, Spring MVC, Jackson JSON -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
</dependencies>

Notice we don't write <version> for the starter. The Parent POM automatically knows the correct version to use.

03application.properties vs application.yml

By default, Spring Boot generates a blank application.properties file in src/main/resources. You can use either .properties or .yml format.

Option 1: application.properties (Flat key-value)

# Change server port from default 8080 to 9090
server.port=9090
# Give your app a custom name
spring.application.name=DevinHyderabad-App

Option 2: application.yml (Hierarchical — Recommended)

Delete the .properties file and create application.yml instead.

server:
port: 9090
spring:
application:
name: DevinHyderabad-App

If you run your app now, it will start on http://localhost:9090.

04Advanced Configuration Examples

More Configuration Examples

Here are some commonly used Spring Boot configurations:

# Database Configuration (MySQL)
spring.datasource.url=jdbc:mysql://localhost:3306/mydb
spring.datasource.username=root
spring.datasource.password=secret
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

# JPA / Hibernate Settings
spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQLDialect

# Logging Level
logging.level.com.devinhyderabad=DEBUG
05Why It Matters / Interview Note

Interview Question: "What is the advantage of Spring Boot Starters?"

Answer: Spring Boot Starters solve the "dependency hell" problem. In traditional Spring, developers had to manually find compatible versions of dozens of libraries (Spring Core, Spring Web, Jackson, Tomcat, etc.) which often led to version conflicts. A Starter like spring-boot-starter-web acts as a single dependency that pulls in all required, fully-tested, and compatible transitive dependencies for a specific feature set.

Key Takeaways

  • ✅ Spring Boot Starters bundle compatible dependencies — no version conflicts
  • ✅ Parent POM (spring-boot-starter-parent) manages all dependency versions
  • ✅ application.properties uses flat key=value; application.yml uses hierarchical YAML
  • ✅ Change server port with server.port=9090 in properties or yml