Spring Boot
Application.yml
Bootstrap.yml
Java
Configuration Properties

What is the difference between putting a property on application.yml or bootstrap.yml in spring boot?

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Introduction

In Spring applications, application.yml is the normal place for application configuration, while bootstrap.yml historically belonged to Spring Cloud’s earlier bootstrap phase. The difference is not only file name. It is about when the properties are loaded and whether the application needs configuration early enough to contact an external config source.

What application.yml Is For

application.yml is the standard Spring Boot configuration file. Most everyday properties belong there: server port, datasource settings, logging levels, Kafka configuration, feature flags, and custom application properties.

yaml
1spring:
2  datasource:
3    url: jdbc:postgresql://localhost:5432/appdb
4    username: app
5    password: secret
6server:
7  port: 8080
8myapp:
9  region: ca-central

These settings are read as part of the normal application configuration process and are used to build the main application context. For many services, this file is all you need.

Why bootstrap.yml Existed

bootstrap.yml was mainly used with Spring Cloud when an application needed some properties before the main context was created. A common example was connecting to Spring Cloud Config Server. The app needed to know its name and the config-server location early, because those values were required to fetch the rest of the configuration.

yaml
1spring:
2  application:
3    name: orders-service
4  cloud:
5    config:
6      uri: http://config-server:8888
7      fail-fast: true

In that older model, bootstrap.yml was loaded before application.yml, creating a bootstrap context whose job was to acquire or prepare configuration for the real application context.

The Modern Caution: bootstrap.yml Is Not Universal

A lot of confusion comes from older Spring Cloud answers being repeated without context. In many modern Spring Boot setups, bootstrap.yml is not automatically part of the story. Projects often use newer configuration mechanisms, such as config imports, and some applications do not need a bootstrap phase at all.

That means the real question is not "which file is better?" It is "does this application need an early bootstrap context?" If the answer is no, put the property in application.yml. If the answer is yes because a Spring Cloud bootstrap process is intentionally enabled, then some early properties may belong in bootstrap.yml.

A Good Rule for Property Placement

A practical rule is:

  1. Put ordinary runtime configuration in application.yml.
  2. Reserve bootstrap.yml for configuration needed before the main application context can be assembled.
  3. If your project does not explicitly use Spring Cloud bootstrap behavior, assume application.yml is the correct place.

That keeps configuration predictable and avoids scattering settings across files without a lifecycle reason.

Example of the Difference in Practice

Imagine a service that reads database credentials from a central config service. The address of that config service may need to be available very early. That is bootstrap-style configuration. But the resolved datasource URL and pool size that the service eventually uses belong with the rest of the application configuration.

So the distinction is not local versus remote configuration. It is early bootstrap configuration versus normal application configuration.

Common Pitfalls

  • Putting ordinary business settings in bootstrap.yml just because an old tutorial did so.
  • Assuming bootstrap.yml is always loaded in every Spring Boot project.
  • Forgetting that many newer projects use different external-config patterns instead of the old bootstrap phase.
  • Splitting related properties across both files without a clear lifecycle reason.
  • Debugging property precedence without first confirming whether bootstrap processing is even enabled.

Summary

  • application.yml is the normal home for standard Spring Boot configuration.
  • bootstrap.yml was historically used for very early Spring Cloud bootstrap properties.
  • The key difference is load timing and whether external configuration must be reached before the main context starts.
  • Many projects do not need bootstrap.yml at all.
  • If a property is not required during bootstrap, application.yml is usually the right place.

Course illustration
Course illustration

All Rights Reserved.