Spring Boot Interview Question

What is the application.properties file in Spring Boot?

Updated 2026-08-16 · Beginner friendly
Quick answer

The application.properties file, or its YAML form application.yml, is where you put configuration for your Spring Boot app, such as the server port, database URL, and logging levels. Spring Boot reads it automatically at startup. You can also keep separate files per environment using profiles, like application-dev.properties and application-prod.properties.

Key takeaways
  • application.properties holds external configuration for a Spring Boot app.
  • It sets values like the server port, database URL, and logging levels.
  • You can also use YAML in application.yml for the same purpose.

What goes in it

server.port=8081
spring.datasource.url=jdbc:mysql://localhost/shop
logging.level.root=INFO

Profiles for each environment

Profiles let you keep different settings for development, testing, and production. You activate one with spring.profiles.active, and Spring loads the matching file, so you never hard code environment specific values.

In the interview

Mention that you keep secrets like passwords out of this file, using environment variables or a secrets manager instead. Raising security here shows maturity that many candidates miss.

Frequently asked questions

How do you read a property in code?

Use the Value annotation to inject a single property, or bind a group of properties to a class with ConfigurationProperties.

How do you support different environments?

Use profile specific files like application-dev.properties and activate a profile, so each environment loads its own settings.

Want the full Spring Boot guide?

Read every Spring Boot concept with notes, diagrams, and code in one place. Track your progress as you go.

Open the Spring Boot guide All Spring Boot questions