Spring Boot
application.properties
configuration file
project structure
Java Spring

Where is the application.properties file in a Spring Boot project?

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

Introduction

In a Spring Boot project, application.properties is the conventional file for application configuration. The short answer is that it normally lives in src/main/resources, but understanding why that location works, how external config overrides it, and how profiles fit in makes the answer much more useful.

Default Location Inside the Project

The standard location is:

text
src/main/resources/application.properties

That folder is placed on the runtime classpath when the application is built, so Spring Boot can discover the file automatically.

A typical project layout looks like this:

text
1my-app/
2  src/
3    main/
4      java/
5      resources/
6        application.properties

If you put the file there, Spring Boot will usually load it with no extra configuration.

What Goes in the File

The file contains key-value settings for the application.

properties
1server.port=8081
2spring.application.name=demo-app
3spring.datasource.url=jdbc:postgresql://localhost:5432/demo
4spring.datasource.username=demo
5spring.datasource.password=secret

These properties influence how Spring Boot configures the embedded server, data sources, logging, and many other features. Because the file is plain text, it is easy to version, review, and override.

Profile-Specific Files

Spring Boot also supports profile-specific variants such as application-dev.properties or application-prod.properties.

text
src/main/resources/application-dev.properties
src/main/resources/application-prod.properties

When a profile is active, Spring Boot combines the base file with the profile-specific file. For example, you might keep shared defaults in application.properties and only override environment-specific values in application-prod.properties.

properties
# application.properties
server.port=8080
properties
# application-prod.properties
server.port=80

Activate a profile with a property or command-line flag:

bash
java -jar app.jar --spring.profiles.active=prod

This is the normal way to keep one codebase but vary configuration across environments.

External Configuration Can Override It

The file does not have to live only inside the project. In deployment, teams often keep sensitive or environment-specific configuration outside the packaged application.

bash
java -jar app.jar --spring.config.location=file:./config/application.properties

This is useful when the same build artifact is deployed to multiple environments and each environment needs different values.

You can also use directories such as ./config next to the JAR. Spring Boot knows several conventional search locations, and external files can override values found on the classpath.

Why Developers Sometimes Cannot Find It

A common source of confusion is that some projects use application.yml instead of application.properties. Both are valid. Another source is that configuration may be split across profiles, external files, environment variables, or command-line arguments.

So if you do not see application.properties in src/main/resources, that does not automatically mean the project is misconfigured. It may simply be using a different supported configuration source.

The practical question is not only "where is the file" but also "which configuration source is winning at runtime." That matters when a value in the file seems to be ignored.

In day-to-day development, this usually means checking the active profile, startup flags, environment variables, and any mounted config directories before assuming the file was not loaded. Spring Boot configuration is flexible, which is powerful, but that flexibility also means the winning value may come from somewhere other than the classpath file.

Common Pitfalls

  • Looking in src/main/java instead of src/main/resources.
  • Forgetting that application.yml may be used instead of application.properties.
  • Editing the base file while a profile-specific or external file is actually overriding the value.
  • Storing secrets in version-controlled properties files when they should come from a safer source.
  • Assuming the file must exist even in projects that rely on environment variables or other config sources.

Summary

  • The default location is src/main/resources/application.properties.
  • Spring Boot loads that file automatically because resources is on the classpath.
  • Profile-specific files such as application-dev.properties extend or override the base config.
  • External configuration can override classpath files in deployed environments.
  • If a setting seems wrong, check all active configuration sources, not just the base file.

Related reading
Course
Intermediate
27 lessons
14 hours
OOD Fundamentals

Master object-oriented design from first principles, SOLID, design patterns, and classic interview problems with hands-on coding.

View the course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

Interview Questions practice on Codemia

Over 8,000 real interview questions from top companies, searchable by company and role.

Browse interview questions

All Rights Reserved.