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.
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.
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:
- Put ordinary runtime configuration in
application.yml. - Reserve
bootstrap.ymlfor configuration needed before the main application context can be assembled. - If your project does not explicitly use Spring Cloud bootstrap behavior, assume
application.ymlis 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.ymljust because an old tutorial did so. - Assuming
bootstrap.ymlis 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.ymlis the normal home for standard Spring Boot configuration.bootstrap.ymlwas 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.ymlat all. - If a property is not required during bootstrap,
application.ymlis usually the right place.

