Troubleshooting YAML Indentation Issues

Use a datasource case to inspect YAML nesting, profile overrides, and final bound values.

Use a datasource example to show how YAML indentation affects Spring Boot property binding and how to inspect it in IntelliJ IDEA.

Symptom

The application still connects to a default datasource, or it reports that datasource url is missing. The developer checks application.yml and sees that spring.datasource.url is present, but the runtime value is not used.

This is easy to misdiagnose as a driver dependency, database connection, or plugin completion problem. The real cause may be that url, username, and password are not nested under datasource.

spring:
  datasource:
  url: jdbc:postgresql://localhost:5432/app
  username: app
  password: secret

Correct configuration

The correct structure makes url, username, and password children of datasource. Visually it is only two spaces, but YAML treats it as a different structure.

In IntelliJ IDEA, place the caret on the key and inspect hierarchy, or use formatting and folding to confirm parent-child relationships. Completion suggestions often change when the nesting level changes.

spring:
  datasource:
    url: jdbc:postgresql://localhost:5432/app
    username: app
    password: secret

Verification steps

After fixing the indentation, start the application with the local profile and confirm from startup logs that the expected datasource is used. If Actuator is enabled, inspect env or configprops to confirm the final bound value.

If the setting still does not work, check whether application-dev.yml overrides datasource or whether startup arguments point to another configuration location.

  • Format the YAML file and inspect nesting
  • Search datasource across all application-*.yml files
  • Confirm the active profile
  • Check startup logs or Actuator output

Related guides

Independently maintained by ErickPang. Not affiliated with Spring, JetBrains, or Broadcom.