Spring Framework
naming conventions
application configuration
Spring best practices
software development

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.

Browse interview questions

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:

yaml
1server:
2  port: 8080
3
4spring:
5  datasource:
6    url: jdbc:postgresql://localhost:5432/app
7
8app:
9  mail:
10    timeout: 5s

When writing flat .properties files, the same idea becomes:

properties
server.port=8080
spring.datasource.url=jdbc:postgresql://localhost:5432/app
app.mail.timeout=5s

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:

java
1import org.springframework.boot.context.properties.ConfigurationProperties;
2
3@ConfigurationProperties(prefix = "app.mail")
4public class MailProperties {
5    private String host;
6    private int port;
7
8    public String getHost() {
9        return host;
10    }
11
12    public void setHost(String host) {
13        this.host = host;
14    }
15
16    public int getPort() {
17        return port;
18    }
19
20    public void setPort(int port) {
21        this.port = port;
22    }
23}

Then configuration like this binds cleanly:

yaml
1app:
2  mail:
3    host: smtp.example.com
4    port: 587

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:

bash
export SPRING_DATASOURCE_URL=jdbc:postgresql://localhost:5432/app
export APP_MAIL_HOST=smtp.example.com

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.properties and application.yaml, with application-{profile} variants for profiles.
  • Property keys are usually lowercase and hierarchical.
  • '@ConfigurationProperties prefixes 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
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.