Spring Boot Application Configuration with YAML

This guide will introduce you to YAML and the YAML support with the various application configuration options that are present in Spring Boot.

You will learn

  • What is application configuration?
  • What is YAML?
  • What are the advantages of YAML?
  • How do you specify application configuration using YAML with Spring Boot?

Spring Boot Courses





10 Step Reference Courses

YAML is a human readable serialization language

YAML stands for Yet Another Markup Language

Let’s consider an example


level1.property1 = 5
level1.property2 = 6
level1.property3 = 7
level1.level2.property4 = 8
level1.level2.property5 = 10
level1.level2.property6 = 11

Above property file is cool but it is not very readable.

Let’s consider the same example in YAML format: application.yaml

  property1: 5
  property2: 6
  property3: 7
     property4: 8
     property5: 10
     property6: 11


  • is concise
  • is more readable

Spring Boot and YAML

Spring Boot has excellent support for YAML configuration.

Example 1


server.port = 9080


	port: 9080

Example 2


app.description=${app.name} is your first Spring Boot application
welcome.message=Welcome message from property file! Welcome to ${app.name}


   name: In28Minutes
   description: ${app.name} is your first Spring Boot application
    message: Welcome to your first Spring Boot app!

Example 3 - Dynamic Configuration


basic.value: true
basic.message: Dynamic Message
basic.number: 100


   value: true
   message: Dynamic Message YAML
   number: 100

Congratulations! You are reading an article from a series of 50+ articles on Spring Boot and Microservices. We also have 20+ projects on our Github repository. For the complete series of 50+ articles and code examples, click here.

Next Steps


Related Posts

Spring Boot Tutorials for Beginners

At in28Minutes, we are creating a number of tutorials with videos, articles & courses on Spring Boot for Beginners and Experienced Developers. This resources will help you learn and gain expertise at Spring Boot.

Spring Boot Basics - What Is A Profile?

When we develop applications, we would want to be able to provide different application configuration in different environments? How do you achieve it with Profiles?

Spring Basics - What Is A Dependency?

Most important feature of Spring Framework is Dependency Injection. To understand Dependency Injection, you need to understand the concept of a Dependency.

Architecture of Spring Framework - Modularity and Spring Modules

One of the most important features of the Spring framework is its modularity. It is not one big monolith framework. What are Spring Modules? How are they organized? What is the architecture of Spring Framework?

What Are Spring Projects?

There are several important Spring Projects solving the needs of enterprises today. What are Spring Projects and how are they different from Spring Modules?

Spring Basics - Introduction To Spring Batch

Spring Batch is a lightweight, comprehensive batch framework that is designed for use in developing robust batch applications.

Spring Framework Basics - What Is Inversion Of Control?

Developers starting with the Spring framework often get confused with terminology - Dependency, Dependency Injection and Inversion Of Control. In this article, we introduce you to the concept of Inversion of Control.

Spring Boot Basics - Introduction To Spring Data and Spring Data JPA

In this article, we take a look at Spring Data and Spring Data JPA.

Spring Basics - Introduction To Spring Framework

In this article, we look to get an introduction to what the Spring framework is, and why it is so widely used.

Spring Boot Basics - Introduction To Spring Data Rest

Spring Data project provides common abstractions to integrate with different kinds of data stores. Spring Data Rest is part of the umbrella of Spring Data projects. It makes it easy to build hypermedia-driven REST web services, on top of Spring Data repositories.