Does Spring follow any naming convention for application configuration?
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
Introduction
Spring itself is flexible, but Spring Boot absolutely does follow configuration naming conventions. They are not arbitrary style preferences. They affect how configuration files are discovered, how profiles are loaded, and how properties bind into @ConfigurationProperties classes.
File Naming Conventions
The most common configuration filenames are:
- '
application.properties' - '
application.yaml' - '
application.yml'
For profile-specific variants, Spring Boot uses:
- '
application-dev.properties' - '
application-prod.yaml' - '
application-test.yml'
That application-{profile} pattern is built into Boot's configuration loading behavior.
Property Key Conventions
Inside configuration files, the standard style is hierarchical lowercase keys. For example:
When writing flat .properties files, the same idea becomes:
So yes, there is a naming convention:
- group related properties by prefix
- use lowercase segments
- separate segments with dots
@ConfigurationProperties Naming
For configuration binding, Spring Boot uses relaxed binding. That means several key shapes can map to the same Java field, but the recommended prefix style is kebab case:
Then configuration like this binds cleanly:
Boot can also bind variants such as app.mail.host, app.mail-host, or environment variable forms, but kebab-style prefixes and structured keys are the clearest convention to publish.
Bean Naming Versus Property Naming
Do not mix these concerns together.
- Java classes use
PascalCase - bean names are typically
camelCase - property keys are lowercase hierarchical names
For example:
- class:
MailProperties - bean name:
mailProperties - config prefix:
app.mail
Spring supports these different styles because they serve different layers of the application.
Environment Variable Mapping
Spring Boot also maps environment variables into properties using uppercase with underscores:
This is another naming convention worth knowing, especially for Docker, Kubernetes, and CI systems.
Spring's relaxed binding is what makes these shapes interoperable. A Java field like maxPoolSize can often bind from keys such as app.datasource.max-pool-size or APP_DATASOURCE_MAX_POOL_SIZE, but publishing one clear canonical style still matters for readability.
Conventions Versus Requirements
Spring is permissive. You can define custom beans, custom property sources, and your own file locations. But the ecosystem is smoothest when you follow the conventional names because:
- auto-configuration expects them
- other developers recognize them immediately
- documentation and tooling align with them
That is the usual Spring tradeoff: convention first, customization when needed.
Common Pitfalls
One common mistake is assuming there is one naming style for everything. File names, bean names, Java types, and property keys each follow different conventions.
Another mistake is inventing random top-level property prefixes instead of grouping settings under a clear domain such as app.mail or acme.payment.
A third issue is mixing environment-variable names and file-property names as if they were identical. Spring maps between them, but they are not written the same way.
Summary
- Spring Boot does follow naming conventions for configuration files and property keys.
- Standard files are
application.propertiesandapplication.yaml, withapplication-{profile}variants for profiles. - Property keys are usually lowercase and hierarchical.
- '
@ConfigurationPropertiesprefixes are best written in kebab-style hierarchical form.' - Spring is flexible, but following the conventions makes auto-configuration and team maintenance much easier.
Related reading
- Does Spring publish beans in thread-safe manner?
- Does Spring @Transactional attribute work on a private method?
- does Spring transactional work with MongoDB?
- Does the Java Memory Model JSR-133 imply that entering a monitor flushes the CPU data caches?
- Does the Java operator apply or ?
- Does the SQL Server JDBC driver support asynchronous operations?
- Does use of final keyword in Java improve the performance?
- Does Weblogic support failover of session objects that are not marked as serializable?

OOD Fundamentals
Master object-oriented design from first principles, SOLID, design patterns, and classic interview problems with hands-on coding.
View the courseTrack 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.