Spring Boot Tutorial 0/110 lessons ~6 min read Lesson 11

    application.properties & YAML

    application.properties and application.yml are interchangeable formats for Spring Boot configuration.

    Course progress0%
    Focus
    4 guided sections
    Practice signal
    Examples included
    Career prep
    Foundation builder

    Introduction

    application.properties and application.yml are interchangeable formats for Spring Boot configuration. YAML is preferred in modern projects: nested, less repetition, supports lists.

    Syntax reference

    bash
    # application.yml — same thing, nested
    server:
    port: 8080
    spring:
    datasource:
    url: jdbc:postgresql://localhost:5432/orders
    jpa:
    hibernate:
    ddl-auto: validate
    logging:
    level:
    com.acme: DEBUG

    Informative example

    The same config in both formats:

    bash
    # application.properties
    server.port=8080
    spring.datasource.url=jdbc:postgresql://localhost:5432/orders
    spring.jpa.hibernate.ddl-auto=validate
    logging.level.com.acme=DEBUG

    Best practices

    • Pick one format per project; mixing causes confusion.
    • Per-env overrides: application-prod.yml activated by SPRING_PROFILES_ACTIVE=prod.
    • Reference env vars: password: ${DB_PASSWORD}.
    Ready to mark this lesson complete?Track your journey across the entire course.