Skip to content

You don’t need every property—you need to understand what problem each category solves. Here’s the clean version:


application.properties — what it really is

This file = runtime configuration

Not build (that’s pom.xml) Not code (that’s Java)

This controls how your app behaves when it runs.


Core structure (think in buckets)

1. Server (how your app is exposed)

server.port=8080
server.servlet.context-path=/app
  • port → where app runs
  • context-path → base URL

If this is wrong → app runs but you can’t reach it.


2. Application identity

spring.application.name=demo

Used in:

  • logs
  • microservices (service discovery)

3. Database (most critical in real apps)

spring.datasource.url=jdbc:mysql://localhost:3306/db
spring.datasource.username=root
spring.datasource.password=pass

This answers:

Where is my data and how do I connect?

Wrong config → app starts but crashes on DB access.


4. JPA / Hibernate (how DB is handled)

spring.jpa.hibernate.ddl-auto=update
spring.jpa.show-sql=true
  • ddl-auto → schema behavior (create/update/none)
  • show-sql → logs queries

If you don’t understand this, you’ll destroy or mismatch your database.


5. Logging (visibility)

logging.level.root=INFO
logging.level.org.springframework=DEBUG

Controls how much you see.

Too little → blind Too much → noise


6. Profiles (environment switching)

spring.profiles.active=dev

Lets you switch configs:

  • dev
  • test
  • prod

Without this → you’ll hardcode everything and regret it later.


7. Custom properties (your own config)

app.feature.enabled=true
app.api.key=xyz

Used in your code via:

@Value("${app.api.key}")

This is how you avoid hardcoding values.


What you’re probably missing

Most beginners treat this file like:

“random place to dump configs”

Wrong.

Each property should answer:

  • What system am I configuring?
  • What happens if this value changes?

If you can’t answer that → you’re guessing.


Mental model

Think in 3 layers:

  1. Server → how app runs
  2. Infrastructure → DB, external systems
  3. Behavior → logging, features, profiles

spring.application.name=demo

for actuator

management.endpoints.web.exposure.include=health,info,beans management.info.env.enabled=true info.app.name=Demo info.app.version=1.0 info.app.description=Demo application for spring

for Logging

logging.level.org=INFO

logging.level.org.springframework=DEBUG

logging.level.org.springframework.web=ERROR

logging.level.org.hibernate=TRACE

spring.datasource.url=jdbc:postgresql://host.docker.internal:5432/claims?currentSchema=claims

spring.datasource.url=jdbc:postgresql://localhost:5432/demo spring.datasource.username=postgres spring.datasource.password=password

HIBERNATE ENGINE CONFIGURATION

Create-drop means create the databse schema when app starts and delete on shutdown

spring.jpa.hibernate.ddl-auto=create-drop

Hibernate has clreated dialect classes for database that wraps drivers

spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.PostgreSQLDialect

defer Spring's data.sql execution until after JPA/Hibernate has created the schema

add below if you use other file name than import.sql

spring.jpa.defer-datasource-initialization=true

where to find the data file (optional if you name it data.sql in resources)

spring.sql.init.data-locations=classpath:/data.sql

show queries generated by hibernate in console

spring.jpa.show-sql=true

ensure Spring runs SQL initialization even for non-embedded DBs

spring.sql.init.mode=always

Format the sql query on console

spring.jpa.properties.hibernate.format_sql=true

add logging config to display SQL statements

logging.level.org.hibernate.SQL = debug

Enable debug logs:

logging.level.com.zaxxer.hikari=DEBUG

spring.datasource.hikari.minimum-idle=1

Hikari?s default pool size is 10

spring.datasource.hikari.maximum-pool-size=20

SWAGGER

springdoc.swagger-ui.path = /demo.html