Spring Boot: Using YAML file inspite of Property files
I am a developer who loves Java, Spring, Quarkus, Micronaut, Open source, Microservices, Cloud
Search for a command to run...
I am a developer who loves Java, Spring, Quarkus, Micronaut, Open source, Microservices, Cloud
No comments yet. Be the first to comment.
Spring AI Tool Calling: From Chatbot to AI Agent with @Tool Your AI is smart. It knows an enormous amount. But it's frozen. It doesn't know what time it is right now. It doesn't know what's on your ca
Spring AI Advisors API Explained Series: Spring AI Complete Course — Lecture 4 of 12Reading Time: 8 minutesLevel: Intermediate Most developers stop at ChatClient. That is enough for demos. It is not
Working with Multiple AI Models in Spring AI Spring AI Complete Course — Lecture 3 of 12Previous: Lecture 2 — ChatClient API | Next: Lecture 4 — Advisors API In production AI applications, you rarel
Spring AI ChatClient API: The Fluent Heart of AI Integration Introduction If you've ever tried integrating AI models into a Java application, you know the pain. HTTP clients, API keys scattered everywhere, vendor-specific SDKs that never quite fit. W...
What is Spring AI? — Why Java Developers Need This in 2026 Every AI tutorial you see is in Python. LangChain, LlamaIndex, OpenAI SDK — all Python. But here's the uncomfortable truth: 80% of enterprise backends run Java. So who's building AI into thos...
Using YAML file
Yaml as they are called Yet Another Markup Language is an alternative to properties file. It has extension of “.yml”. We can create application.yml file instead of application.properties.
Following it table for equivalent properties and YAML
application.properties
app.name=User Application
app.version: 1.0.0
app.description = ${app.name} - ${app.version} is an application to store user details.>
app.developers.name[0]=Ray McFallen
app.developers.name[1]=John Smith
application.yml
app:
name : User Application
Version: 1.0.0
description: ${app.name} - ${app.version} is an application to store user details.
developers:
name:
- Ray McFallen
- John Smith
As we can see yaml file is less repetitive than properties file in term of key namings. The another difference to be noticed is in list of elements (Array in above case) .
Yaml file is lot cleaner approach. With properties file we are creating profile specific properties file i.e. application-{profile}.properties . Which means for each profile there will be separate properties file. With yml , we can use three “-” like — and write profile specific values in same file.
app: name : User Application Version: 1.0.0 --- spring: profiles: development Version: 1.0.40 --- spring: profiles: production Version: 1.0.3
Here version will change if application is started with profiles as development and production but by default (if no profile is given) it will pick 1.0.0 .
The biggest shortcoming of YAML is that you can’t use it with @PropertySource annotation. This annotation is used to load property files other named other than application*properties . PropertySource annotation is used for externalizing properties.