application.properties / application.yml — Spring Technical Interview Questions & Answers

Externalized configuration for a Spring Boot app.

application.properties / application.yml

  • application.properties (or .yml) stores settings outside your Java code.
  • Common keys: server.port, database URL, username, password, logging level.
  • YAML option: application.yml uses indentation instead of flat key=value lines.
  • Read values: @Value("${server.port}") or a @ConfigurationProperties class.
  • Profiles: application-dev.properties / application-prod.properties for each environment.
  • Why useful: Change port or DB without rewriting Java classes.
  • Hardcoding secrets in source code instead of config/env vars.
  • Externalized config keeps the same code running in dev and prod.

Technical Interview Tip: Show one property example and how a profile overrides it.

Code Examples for application.properties / application.yml

application.properties / application.yml — working example

# application.properties
server.port=8081
spring.application.name=gocareergo
spring.profiles.active=dev
spring.datasource.url=jdbc:h2:mem:prep
app.welcome=Hello

# application-dev.properties
# logging.level.root=DEBUG

# application.yml equivalent:
# server:
#   port: 8081
# spring:
#   profiles:
#     active: dev

application.properties / application.yml — externalized config + profiles let one artifact run in dev/stage/prod with different values.

How to Explain application.properties / application.yml to an Interviewer

What is application.properties / application.yml (sb)?

Used for a short application.properties / application.yml sb example a small REST app Not just the heading

Give one small example of application.properties / application.yml (sb).

the smallest application.properties / application.yml sb example you can type Externalized configuration for a Spring Boot app

What mistake do beginners make with application.properties / application.yml (sb)?

only saying “application.properties / application.yml sb” with no example Show the fix

Where do you use application.properties / application.yml (sb)?

a small REST app a short application.properties / application.yml sb example