Spring Boot Application Configuration with YAML

blog details
author Ranga Karanam July 05, 2022 1 minutes

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

Image

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?

What is YAML?

YAML is a human readable serialization language

YAML stands for Yet Another Markup Language

Let鈥檚 consider an example

application.properties

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鈥檚 consider the same example in YAML format: application.yaml

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

YAML

  • is concise
  • is more readable

Spring Boot and YAML

Spring Boot has excellent support for YAML configuration.

Example 1

application.properties

server.port = 9080

application.yaml

server:
	port: 9080

Example 2

application.properties

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

application.yaml

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

Example 3 - Dynamic Configuration

application.properties

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

application.yaml

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

Complete project with code example - https://github.com/in28minutes/spring-boot-examples/tree/master/spring-boot-tutorial-basics-configuration

Just Released

ad banner
about-image

Related Articles

  • author
    Spring Profile - Quick Tutorial for Beginners
  • author
    Microservices Architectures - What is Service Discovery?
  • author
    Index - 500+ Videos
  • author
    Spring Boot Tutorials for Beginners
  • author
    Introduction To Spring Boot Framework - A Quick Tutorial for Beginners
  • author
    Introduction To Spring Data Rest - Quick Tutorial for Beginners
  • author
    Spring Batch Tutorial for Beginners
  • author
    What Are Spring Projects?
  • author
    Getting Started with Spring Boot - 7 things a beginner should know!
  • author
    Versioning RESTful Services - Spring Boot REST API
  • author
    Creating a SOAP Web Service with Spring Boot Starter Web Services
  • author
    20+ Spring Boot Projects with Code Examples
  • author
    Spring Boot REST API Projects with Code Examples
  • author
    Spring Boot Exception Handling for RESTful Services Errors
  • author
    Implementing Validation for RESTful Services with Spring Boot

Related Courses

ad banner
ad banner
ad banner

4617作文网女装店起名流行简单有创意的空调公司起名给宝宝起名姓姚算死命免费下载全集周公解梦梦见警察139算命最准的免费网站 新闻今年属鼠女孩起什么名字好美发的店名起什么名好1518解梦大全查询八字起名 周易白白解说精灵宝可梦剑盾想孩子起名八字起名免费评分测试珠宝品牌商标起名周义起起名起个名字是男的解梦打车周易预测日本国运排八字算命软件姓名测试周易免费取名测名字打分周易八字命理分析老版周公解梦大全周易免费测算测运势给舞蹈起个名字贸易公司名字起名大全宣起名车运输公司起名大全算死命是什么马铃薯起名周公解梦直码册淀粉肠小王子日销售额涨超10倍罗斯否认插足凯特王妃婚姻让美丽中国“从细节出发”清明节放假3天调休1天男子给前妻转账 现任妻子起诉要回网友建议重庆地铁不准乘客携带菜筐月嫂回应掌掴婴儿是在赶虫子重庆警方辟谣“男子杀人焚尸”国产伟哥去年销售近13亿新的一天从800个哈欠开始男孩疑遭霸凌 家长讨说法被踢出群高中生被打伤下体休学 邯郸通报男子持台球杆殴打2名女店员被抓19岁小伙救下5人后溺亡 多方发声单亲妈妈陷入热恋 14岁儿子报警两大学生合买彩票中奖一人不认账德国打算提及普京时仅用姓名山西省委原副书记商黎光被逮捕武汉大学樱花即将进入盛花期今日春分张家界的山上“长”满了韩国人?特朗普谈“凯特王妃P图照”王树国3次鞠躬告别西交大师生白宫:哈马斯三号人物被杀代拍被何赛飞拿着魔杖追着打315晚会后胖东来又人满为患了房客欠租失踪 房东直发愁倪萍分享减重40斤方法“重生之我在北大当嫡校长”槽头肉企业被曝光前生意红火手机成瘾是影响睡眠质量重要因素考生莫言也上北大硕士复试名单了妈妈回应孩子在校撞护栏坠楼网友洛杉矶偶遇贾玲呼北高速交通事故已致14人死亡西双版纳热带植物园回应蜉蝣大爆发男孩8年未见母亲被告知被遗忘张立群任西安交通大学校长恒大被罚41.75亿到底怎么缴沈阳一轿车冲入人行道致3死2伤奥运男篮美国塞尔维亚同组周杰伦一审败诉网易国标起草人:淀粉肠是低配版火腿肠外国人感慨凌晨的中国很安全男子被流浪猫绊倒 投喂者赔24万杨倩无缘巴黎奥运男子被猫抓伤后确诊“猫抓病”春分“立蛋”成功率更高?记者:伊万改变了国足氛围奥巴马现身唐宁街 黑色着装引猜测

4617作文网 XML地图 TXT地图 虚拟主机 SEO 网站制作 网站优化