{"id":16473,"date":"2024-10-29T15:12:49","date_gmt":"2024-10-29T07:12:49","guid":{"rendered":"https:\/\/92it.top\/?p=16473"},"modified":"2025-04-17T13:33:42","modified_gmt":"2025-04-17T05:33:42","slug":"yaml%e6%96%87%e4%bb%b6%e6%b7%b1%e5%ba%a6%e5%88%86%e6%9e%90%ef%bc%81","status":"publish","type":"post","link":"https:\/\/92it.top\/?p=16473","title":{"rendered":"YAML\u6587\u4ef6\u6df1\u5ea6\u5206\u6790\uff01"},"content":{"rendered":"\n<p>\u8f6c\u8f7d\uff1a<a href=\"https:\/\/mp.weixin.qq.com\/s?__biz=MzIwNDAyOTI2Nw==&amp;mid=2247500111&amp;idx=1&amp;sn=5a763ddb23c1ece2191bdf00a1dfc795&amp;chksm=96c4ed73a1b364656a397e82a80710afd6dd0bf7980ee6ba3856ba5f7b0924f9c8922567e25a&amp;cur_album_id=2818595943724974083&amp;scene=190#rd\">YAML\u6587\u4ef6\u6df1\u5ea6\u5206\u6790\uff01<\/a><\/p>\n\n\n\n<p>YAML \u662f\u975e\u5e38\u6d41\u884c\u7684\u4e00\u79cd\u914d\u7f6e\u6587\u4ef6\u683c\u5f0f\uff0c\u65e0\u8bba\u662f\u524d\u7aef\u8fd8\u662f\u540e\u7aef\uff0c\u90fd\u53ef\u4ee5\u89c1\u5230 YAML\u914d\u7f6e\u3002\u90a3\u4e48 YAML \u914d\u7f6e\u548c\u4f20\u7edf\u7684 XML, JSON, properties \u914d\u7f6e\u76f8\u6bd4\uff0c\u5230\u5e95\u6709\u4ec0\u4e48\u4f18\u52bf\uff1f\u8fd9\u7bc7\u6587\u7ae0\uff0c\u6211\u4eec\u6765\u8be6\u7ec6\u7684\u804a\u4e00\u804a\u3002<\/p>\n\n\n\n<p><strong>YAML\u6982\u8ff0<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>YAML\uff08YAML Ain&#8217;t Markup Language\uff09\u7684\u8bbe\u8ba1\u521d\u8877\u662f\u4e3a\u4e86\u63d0\u4f9b\u4e00\u79cd\u6bd4 XML \u66f4\u52a0\u7b80\u6d01\u548c\u6613\u8bfb\u7684\u914d\u7f6e\u6587\u4ef6\u683c\u5f0f\uff0c\u540c\u65f6\u4e5f\u6bd4 JSON\u66f4\u52a0\u4eba\u6027\u5316\u3002YAML \u7684\u57fa\u672c\u539f\u7406\u662f\u901a\u8fc7\u7f29\u8fdb\u548c\u7b80\u5355\u7684\u6807\u8bb0\u6765\u8868\u793a\u6570\u636e\u7ed3\u6784\uff0c\u5b83\u652f\u6301\u591a\u79cd\u6570\u636e\u7c7b\u578b\uff0c\u5305\u62ec\u6807\u91cf\uff08\u5982\u5b57\u7b26\u4e32\u3001\u6574\u6570\uff09\u3001\u5217\u8868\uff08\u6570\u7ec4\uff09\u548c\u5b57\u5178\uff08\u952e\u503c\u5bf9\uff09\u3002<\/p>\n\n\n\n<p>YAML \u652f\u6301\u6ce8\u91ca\uff0c\u4f7f\u7528 <code>#<\/code> \u5f00\u5934\u3002\u6ce8\u91ca\u53ef\u4ee5\u653e\u5728\u884c\u7684\u672b\u5c3e\uff0c\u4e5f\u53ef\u4ee5\u72ec\u5360\u4e00\u884c\u3002<\/p>\n\n\n\n<p><strong>\u6570\u636e\u8868\u793a<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>YAML\u6587\u4ef6\u4e2d\u7684\u6570\u636e\u7ed3\u6784\u5305\u542b\u4ee5\u4e0b\u51e0\u79cd\uff1a<\/p>\n\n\n\n<ol>\n<li><strong>\u6807\u91cf\uff08Scalars\uff09<\/strong>\uff1a\u6807\u91cf\u662f\u6700\u57fa\u672c\u7684\u6570\u636e\u7c7b\u578b\uff0c\u53ef\u4ee5\u662f\u5b57\u7b26\u4e32\u3001\u5e03\u5c14\u503c\u3001\u6574\u6570\u3001\u6d6e\u70b9\u6570\u7b49\u3002\u5728 YAML \u4e2d\uff0c\u6807\u91cf\u53ef\u4ee5\u7528\u591a\u79cd\u65b9\u5f0f\u8868\u793a\uff0c\u5982\u76f4\u63a5\u5199\u51fa\u3001\u7528\u5f15\u53f7\u62ec\u8d77\u7b49\u3002<\/li>\n\n\n\n<li><strong>\u5217\u8868\uff08Sequences\uff09<\/strong>\uff1a\u5217\u8868\u662f\u4e00\u7ec4\u6709\u5e8f\u7684\u6570\u636e\uff0c\u53ef\u4ee5\u7528\u8fde\u5b57\u7b26\uff08<code>-<\/code>\uff09\u5f00\u5934\u7684\u884c\u6765\u8868\u793a\u3002<\/li>\n\n\n\n<li><strong>\u5b57\u5178\uff08Mappings\uff09<\/strong>\uff1a\u5b57\u5178\u662f\u4e00\u7ec4\u65e0\u5e8f\u7684\u952e\u503c\u5bf9\uff0c\u7528\u5192\u53f7\uff08<code>:<\/code>\uff09\u5206\u9694\u952e\u548c\u503c\u3002<\/li>\n\n\n\n<li><strong>\u590d\u5408\u7ed3\u6784<\/strong>\uff1aYAML \u5141\u8bb8\u5d4c\u5957\u4f7f\u7528\u5217\u8868\u548c\u5b57\u5178\u6765\u8868\u793a\u590d\u6742\u7684\u6570\u636e\u7ed3\u6784\u3002<\/li>\n<\/ol>\n\n\n\n<p><strong>YAML \u7684\u8bed\u6cd5<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>YAML \u7684\u8bed\u6cd5\u975e\u5e38\u7b80\u6d01\uff0c\u4e3b\u8981\u4f9d\u8d56\u4e8e\u7f29\u8fdb\u6765\u8868\u793a\u6570\u636e\u7684\u5c42\u6b21\u7ed3\u6784\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u57fa\u672c\u7684\u8bed\u6cd5\u89c4\u5219\uff1a<\/p>\n\n\n\n<ol>\n<li><strong>\u7f29\u8fdb<\/strong>\uff1aYAML \u4f7f\u7528\u7a7a\u683c\u7f29\u8fdb\u6765\u8868\u793a\u5c42\u7ea7\u5173\u7cfb\uff0c\u901a\u5e38\u4f7f\u7528\u4e24\u4e2a\u7a7a\u683c\u3002\u7f29\u8fdb\u5fc5\u987b\u4e00\u81f4\uff0c\u4e0d\u80fd\u6df7\u7528\u7a7a\u683c\u548c\u5236\u8868\u7b26\u3002<\/li>\n\n\n\n<li><strong>\u952e\u503c\u5bf9<\/strong>\uff1a\u5b57\u5178\u4e2d\u7684\u952e\u503c\u5bf9\u7528\u5192\u53f7\u5206\u9694\uff0c\u5192\u53f7\u540e\u9762\u8981\u6709\u4e00\u4e2a\u7a7a\u683c\u3002<\/li>\n\n\n\n<li><strong>\u5217\u8868\u9879<\/strong>\uff1a\u5217\u8868\u9879\u7528\u8fde\u5b57\u7b26\uff08<code>-<\/code>\uff09\u5f00\u5934\uff0c\u8fde\u5b57\u7b26\u540e\u9762\u8981\u6709\u4e00\u4e2a\u7a7a\u683c\u3002<\/li>\n\n\n\n<li><strong>\u5b57\u7b26\u4e32<\/strong>\uff1a\u5b57\u7b26\u4e32\u53ef\u4ee5\u76f4\u63a5\u5199\u51fa\uff0c\u4e5f\u53ef\u4ee5\u7528\u5355\u5f15\u53f7\u6216\u53cc\u5f15\u53f7\u62ec\u8d77\u3002\u5176\u4e2d\uff0c\u5355\u5f15\u53f7\u7528\u4e8e\u4fdd\u7559\u5b57\u7b26\u4e32\u4e2d\u7684\u7279\u6b8a\u5b57\u7b26\uff0c\u53cc\u5f15\u53f7\u53ef\u7528\u4e8e\u8f6c\u4e49\u5b57\u7b26\u3002<\/li>\n\n\n\n<li><strong>\u591a\u884c\u5b57\u7b26\u4e32<\/strong>\uff1aYAML \u652f\u6301\u591a\u884c\u5b57\u7b26\u4e32\uff0c\u53ef\u4ee5\u4f7f\u7528 <code>|<\/code> \u6216 <code>&gt;<\/code> \u6765\u8868\u793a\u3002<code>|<\/code> \u8868\u793a\u4fdd\u7559\u6362\u884c\uff0c<code>&gt;<\/code> \u8868\u793a\u6298\u53e0\u6362\u884c\u3002<\/li>\n\n\n\n<li><strong>\u5e03\u5c14\u503c<\/strong>\uff1a\u5e03\u5c14\u503c\u7528 <code>true<\/code> \u548c <code>false<\/code> \u8868\u793a\uff0c\u5927\u5c0f\u5199\u4e0d\u654f\u611f\u3002<\/li>\n\n\n\n<li><strong>\u7a7a\u503c<\/strong>\uff1a\u7a7a\u503c\u53ef\u4ee5\u7528 <code>~<\/code> \u6216 <code>null<\/code> \u8868\u793a\u3002<\/li>\n<\/ol>\n\n\n\n<p>\u4e3a\u4e86\u66f4\u597d\u5730\u5c55\u793a YAML\uff0c\u4e0b\u9762\u7684\u793a\u4f8b\u5c55\u793a\u4e86\u4e0d\u540c\u7684\u6570\u636e\u7ed3\u6784\u548c\u8bed\u6cd5\u7279\u6027\u3002<\/p>\n\n\n\n<p><strong>1. \u7b80\u5355\u7684\u914d\u7f6e\u6587\u4ef6<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># \u5e94\u7528\u7a0b\u5e8f\u914d\u7f6e\napp:\n  name: MyApp\n  version: 1.0.0\n  debug: true<\/pre>\n\n\n\n<p><strong>2. \u5217\u8868\u548c\u5b57\u5178\u7684\u5d4c\u5957<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># \u670d\u52a1\u5668\u5217\u8868\nservers:\n  - name: server1\n    ip: 192.168.1.1\n    roles:\n      - web\n      - database\n  - name: server2\n    ip: 192.168.1.2\n    roles:\n      - web<\/pre>\n\n\n\n<p><strong>3. \u591a\u884c\u5b57\u7b26\u4e32<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># \u591a\u884c\u5b57\u7b26\u4e32\u793a\u4f8b\ndescription: |\n  \u8fd9\u662f\u4e00\u4e2a\u591a\u884c\u5b57\u7b26\u4e32\u793a\u4f8b\u3002\n  \u6bcf\u4e00\u884c\u90fd\u4f1a\u4fdd\u7559\u6362\u884c\u7b26\u3002\n\nnote: >\n  \u8fd9\u662f\u53e6\u4e00\u4e2a\u591a\u884c\u5b57\u7b26\u4e32\u793a\u4f8b\u3002\n  \u6362\u884c\u7b26\u5c06\u88ab\u6298\u53e0\u4e3a\u4e00\u4e2a\u7a7a\u683c\u3002<\/pre>\n\n\n\n<p><strong>4. \u590d\u6742\u7684\u6570\u636e\u7ed3\u6784<\/strong><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># \u590d\u6742\u6570\u636e\u7ed3\u6784\ndata:\n  users:\n    - name: Alice\n      age: 30\n      contact:\n        email: alice@example.com\n        phone: 123-456-7890\n    - name: Bob\n      age: 25\n      contact:\n        email: bob@example.com\n        phone: 987-654-3210\n  settings:\n    theme: dark\n    notifications: true<\/pre>\n\n\n\n<p><strong>YAML \u7684\u5e94\u7528<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>YAML \u5728\u8bb8\u591a\u9886\u57df\u6709\u5e7f\u6cdb\u7684\u5e94\u7528\uff0c\u5c24\u5176\u662f\u5728\u914d\u7f6e\u7ba1\u7406\u548c\u6570\u636e\u4ea4\u6362\u4e2d\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u89c1\u7684\u5e94\u7528\u573a\u666f\uff1a<\/p>\n\n\n\n<ol>\n<li><strong>\u914d\u7f6e\u6587\u4ef6<\/strong>\uff1a\u8bb8\u591a\u8f6f\u4ef6\u548c\u6846\u67b6\u4f7f\u7528 YAML \u4f5c\u4e3a\u914d\u7f6e\u6587\u4ef6\u683c\u5f0f\uff0c\u4f8b\u5982 Kubernetes\u3001Ansible \u548c Docker Compose\u3002YAML \u7684\u53ef\u8bfb\u6027\u548c\u7b80\u6d01\u6027\u4f7f\u5176\u975e\u5e38\u9002\u5408\u7528\u4e8e\u914d\u7f6e\u6587\u4ef6\u3002<\/li>\n\n\n\n<li><strong>\u6570\u636e\u5e8f\u5217\u5316<\/strong>\uff1aYAML \u53ef\u4ee5\u7528\u4f5c\u6570\u636e\u5e8f\u5217\u5316\u683c\u5f0f\uff0c\u7528\u4e8e\u5728\u4e0d\u540c\u7684\u7f16\u7a0b\u8bed\u8a00\u4e4b\u95f4\u8fdb\u884c\u6570\u636e\u4ea4\u6362\u3002\u8bb8\u591a\u7f16\u7a0b\u8bed\u8a00\u90fd\u6709 YAML \u7684\u89e3\u6790\u5e93\uff0c\u53ef\u4ee5\u65b9\u4fbf\u5730\u5c06 YAML \u8f6c\u6362\u4e3a\u539f\u751f\u7684\u6570\u636e\u7ed3\u6784\u3002<\/li>\n\n\n\n<li><strong>\u6587\u6863\u683c\u5f0f<\/strong>\uff1a\u7531\u4e8e YAML \u7684\u53ef\u8bfb\u6027\uff0c\u5b83\u4e5f\u53ef\u4ee5\u7528\u4e8e\u7f16\u5199\u7b80\u5355\u7684\u6587\u6863\uff0c\u5c24\u5176\u662f\u5f53\u6587\u6863\u9700\u8981\u5d4c\u5165\u4e00\u4e9b\u7ed3\u6784\u5316\u6570\u636e\u65f6\u3002<\/li>\n<\/ol>\n\n\n\n<p><strong>YAML \u4e0e\u5176\u4ed6\u683c\u5f0f\u7684\u6bd4\u8f83<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p><strong>YAML vs <code>.properties<\/code>\u6587\u4ef6<\/strong><\/p>\n\n\n\n<p>YAML \u548c\u5c5e\u6027\u6587\u4ef6\uff08\u901a\u5e38\u662f Java \u7684 <code>.properties<\/code> \u6587\u4ef6\uff09\u90fd\u662f\u7528\u4e8e\u914d\u7f6e\u5e94\u7528\u7a0b\u5e8f\u7684\u6587\u4ef6\u683c\u5f0f\uff0c\u4f46\u5b83\u4eec\u6709\u4e0d\u540c\u7684\u7279\u6027\u548c\u4f7f\u7528\u573a\u666f\u3002\u4e0b\u9762\u6211\u4eec\u6765\u8be6\u7ec6\u6bd4\u8f83\u4e00\u4e0b\u8fd9\u4e24\u79cd\u683c\u5f0f\u3002<\/p>\n\n\n\n<p><strong>\u53ef\u8bfb\u6027\u548c\u7ed3\u6784<\/strong><\/p>\n\n\n\n<p><strong>YAML:<\/strong><\/p>\n\n\n\n<ul>\n<li><strong>\u53ef\u8bfb\u6027\u5f3a<\/strong>\uff1aYAML \u662f\u4e00\u79cd\u4eba\u7c7b\u53ef\u8bfb\u7684\u683c\u5f0f\uff0c\u8bbe\u8ba1\u4e0a\u6ce8\u91cd\u7b80\u6d01\u548c\u6613\u8bfb\u3002\u5b83\u4f7f\u7528\u7f29\u8fdb\u6765\u8868\u793a\u5c42\u6b21\u7ed3\u6784\uff0c\u4f7f\u5f97\u914d\u7f6e\u6587\u4ef6\u975e\u5e38\u76f4\u89c2\u3002<\/li>\n\n\n\n<li><strong>\u652f\u6301\u590d\u6742\u6570\u636e\u7ed3\u6784<\/strong>\uff1aYAML \u53ef\u4ee5\u8f7b\u677e\u8868\u793a\u5d4c\u5957\u7684\u6570\u636e\u7ed3\u6784\uff0c\u5305\u62ec\u5217\u8868\u3001\u5b57\u5178\uff08\u6620\u5c04\uff09\u3001\u591a\u884c\u5b57\u7b26\u4e32\u7b49\u3002<\/li>\n\n\n\n<li><strong>\u652f\u6301\u6ce8\u91ca<\/strong>\uff1aYAML \u652f\u6301\u4f7f\u7528 <code>#<\/code> \u6765\u6dfb\u52a0\u6ce8\u91ca\uff0c\u8fd9\u5728\u914d\u7f6e\u6587\u4ef6\u4e2d\u975e\u5e38\u6709\u7528\u3002<\/li>\n<\/ul>\n\n\n\n<p><strong>Properties:<\/strong><\/p>\n\n\n\n<ul>\n<li><strong>\u7b80\u5355\u5e73\u9762\u7ed3\u6784<\/strong>\uff1a\u5c5e\u6027\u6587\u4ef6\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u952e\u503c\u5bf9\u5217\u8868\uff0c\u5929\u7136\u662f\u5e73\u9762\u7684\uff0c\u4e0d\u652f\u6301\u5d4c\u5957\u7ed3\u6784\u3002<\/li>\n\n\n\n<li><strong>\u53ef\u8bfb\u6027\u4e00\u822c<\/strong>\uff1a\u7531\u4e8e\u5c5e\u6027\u6587\u4ef6\u53ea\u652f\u6301\u7b80\u5355\u7684\u952e\u503c\u5bf9\uff0c\u590d\u6742\u7684\u914d\u7f6e\u53ef\u80fd\u9700\u8981\u901a\u8fc7\u547d\u540d\u7ea6\u5b9a\u6765\u6a21\u62df\u5c42\u6b21\u7ed3\u6784\uff0c\u5f71\u54cd\u53ef\u8bfb\u6027\u3002<\/li>\n\n\n\n<li><strong>\u6709\u9650\u7684\u6ce8\u91ca\u652f\u6301<\/strong>\uff1a\u5c5e\u6027\u6587\u4ef6\u652f\u6301\u4f7f\u7528 <code>#<\/code> \u6216 <code>!<\/code> \u6dfb\u52a0\u6ce8\u91ca\uff0c\u4f46\u7531\u4e8e\u5176\u5e73\u9762\u7ed3\u6784\uff0c\u6ce8\u91ca\u7684\u4e0a\u4e0b\u6587\u4e0d\u5982 YAML \u660e\u786e\u3002<\/li>\n<\/ul>\n\n\n\n<p><strong>\u6570\u636e\u7c7b\u578b\u652f\u6301<\/strong><\/p>\n\n\n\n<p><strong>YAML:<\/strong><\/p>\n\n\n\n<ul>\n<li><strong>\u4e30\u5bcc\u7684\u6570\u636e\u7c7b\u578b<\/strong>\uff1aYAML \u652f\u6301\u591a\u79cd\u6570\u636e\u7c7b\u578b\uff0c\u5305\u62ec\u5b57\u7b26\u4e32\u3001\u6574\u6570\u3001\u6d6e\u70b9\u6570\u3001\u5e03\u5c14\u503c\u3001\u65e5\u671f\u7b49\u3002<\/li>\n\n\n\n<li><strong>\u7075\u6d3b\u7684\u5b57\u7b26\u4e32\u5904\u7406<\/strong>\uff1a\u652f\u6301\u591a\u884c\u5b57\u7b26\u4e32\u3001\u5f15\u53f7\u5b57\u7b26\u4e32\u3001\u88f8\u5b57\u7b26\u4e32\u7b49\u591a\u79cd\u8868\u793a\u65b9\u5f0f\u3002<\/li>\n<\/ul>\n\n\n\n<p><strong>Properties:<\/strong><\/p>\n\n\n\n<ul>\n<li><strong>\u5b57\u7b26\u4e32\u4e3a\u4e3b<\/strong>\uff1a\u5c5e\u6027\u6587\u4ef6\u4e2d\u7684\u503c\u9ed8\u8ba4\u90fd\u662f\u5b57\u7b26\u4e32\uff0c\u5176\u4ed6\u6570\u636e\u7c7b\u578b\u9700\u8981\u5728\u5e94\u7528\u7a0b\u5e8f\u4e2d\u8fdb\u884c\u8f6c\u6362\u3002<\/li>\n\n\n\n<li><strong>\u7b80\u5355\u7684\u5b57\u7b26\u4e32\u5904\u7406<\/strong>\uff1a\u4e0d\u652f\u6301\u591a\u884c\u5b57\u7b26\u4e32\uff0c\u6240\u6709\u5185\u5bb9\u5fc5\u987b\u5728\u4e00\u884c\u5185\u5b8c\u6210\u3002<\/li>\n<\/ul>\n\n\n\n<p><strong>\u6269\u5c55\u6027\u548c\u7075\u6d3b\u6027<\/strong><\/p>\n\n\n\n<p><strong>YAML:<\/strong><\/p>\n\n\n\n<ul>\n<li><strong>\u9ad8\u6269\u5c55\u6027<\/strong>\uff1a\u7531\u4e8e\u652f\u6301\u590d\u6742\u7684\u6570\u636e\u7ed3\u6784\uff0cYAML \u975e\u5e38\u9002\u5408\u7528\u4e8e\u63cf\u8ff0\u590d\u6742\u7684\u914d\u7f6e\u548c\u6570\u636e\u3002<\/li>\n\n\n\n<li><strong>\u7075\u6d3b\u6027<\/strong>\uff1aYAML \u53ef\u4ee5\u7528\u4e8e\u591a\u79cd\u7528\u9014\uff0c\u4e0d\u4ec5\u9650\u4e8e\u914d\u7f6e\u6587\u4ef6\uff0c\u8fd8\u53ef\u4ee5\u7528\u4e8e\u6570\u636e\u5e8f\u5217\u5316\u7b49\u3002<\/li>\n<\/ul>\n\n\n\n<p><strong>Properties:<\/strong><\/p>\n\n\n\n<ul>\n<li><strong>\u6709\u9650\u7684\u6269\u5c55\u6027<\/strong>\uff1a\u5c5e\u6027\u6587\u4ef6\u4e3b\u8981\u7528\u4e8e\u7b80\u5355\u7684\u914d\u7f6e\uff0c\u4e0d\u9002\u5408\u63cf\u8ff0\u590d\u6742\u7684\u6570\u636e\u7ed3\u6784\u3002<\/li>\n\n\n\n<li><strong>\u4e13\u7528\u6027<\/strong>\uff1a\u4e3b\u8981\u4e3a Java \u5e94\u7528\u7a0b\u5e8f\u8bbe\u8ba1\uff0c\u4f7f\u7528\u573a\u666f\u76f8\u5bf9\u6709\u9650\u3002<\/li>\n<\/ul>\n\n\n\n<p><strong>\u4f7f\u7528\u573a\u666f<\/strong><\/p>\n\n\n\n<p><strong>YAML:<\/strong><\/p>\n\n\n\n<ul>\n<li><strong>\u914d\u7f6e\u7ba1\u7406<\/strong>\uff1a\u9002\u7528\u4e8e\u9700\u8981\u590d\u6742\u914d\u7f6e\u7684\u5e94\u7528\u7a0b\u5e8f\uff0c\u5982 Kubernetes\u3001Ansible \u7b49\u3002<\/li>\n\n\n\n<li><strong>\u6570\u636e\u4ea4\u6362<\/strong>\uff1a\u53ef\u4ee5\u7528\u4e8e\u4e0d\u540c\u7cfb\u7edf\u4e4b\u95f4\u7684\u6570\u636e\u4ea4\u6362\u3002<\/li>\n\n\n\n<li><strong>\u6587\u6863\u63cf\u8ff0<\/strong>\uff1a\u7531\u4e8e\u5176\u53ef\u8bfb\u6027\uff0c\u4e5f\u53ef\u4ee5\u7528\u4e8e\u7b80\u5355\u6587\u6863\u7684\u63cf\u8ff0\u3002<\/li>\n<\/ul>\n\n\n\n<p><strong>Properties:<\/strong><\/p>\n\n\n\n<ul>\n<li><strong>Java \u5e94\u7528\u914d\u7f6e<\/strong>\uff1a\u5e7f\u6cdb\u7528\u4e8e Java \u5e94\u7528\u7a0b\u5e8f\u7684\u914d\u7f6e\uff0c\u5c24\u5176\u662f\u4f20\u7edf\u7684 Java EE \u548c Spring \u5e94\u7528\u3002<\/li>\n\n\n\n<li><strong>\u7b80\u5355\u914d\u7f6e<\/strong>\uff1a\u9002\u5408\u4e8e\u7b80\u5355\u7684\u952e\u503c\u5bf9\u914d\u7f6e\uff0c\u4e0d\u9700\u8981\u590d\u6742\u7684\u7ed3\u6784\u3002<\/li>\n<\/ul>\n\n\n\n<p><strong>\u6027\u80fd\u548c\u652f\u6301<\/strong><\/p>\n\n\n\n<p><strong>YAML:<\/strong><\/p>\n\n\n\n<ul>\n<li><strong>\u89e3\u6790\u6027\u80fd<\/strong>\uff1a\u7531\u4e8e\u5176\u590d\u6742\u6027\uff0cYAML \u7684\u89e3\u6790\u901f\u5ea6\u901a\u5e38\u6bd4\u5c5e\u6027\u6587\u4ef6\u6162\uff0c\u4f46\u73b0\u4ee3\u89e3\u6790\u5668\u6027\u80fd\u5df2\u7ecf\u8db3\u591f\u6ee1\u8db3\u5927\u591a\u6570\u5e94\u7528\u9700\u6c42\u3002<\/li>\n\n\n\n<li><strong>\u5e7f\u6cdb\u652f\u6301<\/strong>\uff1a\u6709\u8bb8\u591a\u7f16\u7a0b\u8bed\u8a00\u7684\u5e93\u652f\u6301 YAML \u7684\u89e3\u6790\u548c\u751f\u6210\u3002<\/li>\n<\/ul>\n\n\n\n<p><strong>Properties:<\/strong><\/p>\n\n\n\n<ul>\n<li><strong>\u9ad8\u6548\u89e3\u6790<\/strong>\uff1a\u7531\u4e8e\u5176\u7b80\u5355\u6027\uff0c\u5c5e\u6027\u6587\u4ef6\u7684\u89e3\u6790\u901f\u5ea6\u975e\u5e38\u5feb\u3002<\/li>\n\n\n\n<li><strong>Java \u539f\u751f\u652f\u6301<\/strong>\uff1a\u4f5c\u4e3a Java \u5e73\u53f0\u7684\u4e00\u90e8\u5206\uff0c\u5c5e\u6027\u6587\u4ef6\u6709\u7740\u826f\u597d\u7684\u539f\u751f\u652f\u6301\u3002<\/li>\n<\/ul>\n\n\n\n<p><strong>YAML vs. JSON<\/strong><\/p>\n\n\n\n<p>YAML \u548c JSON \u90fd\u662f\u5e38\u7528\u7684\u6570\u636e\u5e8f\u5217\u5316\u683c\u5f0f\uff0c\u4f46\u5b83\u4eec\u6709\u4e00\u4e9b\u663e\u8457\u7684\u533a\u522b\uff1a<\/p>\n\n\n\n<ul>\n<li><strong>\u53ef\u8bfb\u6027<\/strong>\uff1aYAML \u66f4\u52a0\u4eba\u7c7b\u53ef\u8bfb\uff0c\u9002\u5408\u624b\u52a8\u7f16\u8f91\uff0c\u800c JSON \u66f4\u9002\u5408\u673a\u5668\u5904\u7406\u3002<\/li>\n\n\n\n<li><strong>\u683c\u5f0f\u590d\u6742\u5ea6<\/strong>\uff1aYAML \u652f\u6301\u66f4\u590d\u6742\u7684\u6570\u636e\u7ed3\u6784\u548c\u7c7b\u578b\uff0c\u5982\u591a\u884c\u5b57\u7b26\u4e32\u548c\u6ce8\u91ca\uff0c\u800c JSON \u5219\u4e0d\u652f\u6301\u6ce8\u91ca\u3002<\/li>\n\n\n\n<li><strong>\u6570\u636e\u7c7b\u578b<\/strong>\uff1aYAML \u652f\u6301\u66f4\u591a\u7684\u6570\u636e\u7c7b\u578b\uff0c\u5982\u65e5\u671f\u3001\u65f6\u95f4\u3001\u6b63\u5219\u8868\u8fbe\u5f0f\u7b49\uff0c\u800c JSON \u53ea\u652f\u6301\u5b57\u7b26\u4e32\u3001\u6570\u5b57\u3001\u5e03\u5c14\u503c\u3001\u6570\u7ec4\u548c\u5bf9\u8c61\u3002<\/li>\n<\/ul>\n\n\n\n<p><strong>YAML vs. XML<\/strong><\/p>\n\n\n\n<p>YAML \u548c XML \u90fd\u53ef\u4ee5\u7528\u4e8e\u914d\u7f6e\u6587\u4ef6\u548c\u6570\u636e\u4ea4\u6362\uff0c\u4f46\u5b83\u4eec\u6709\u5f88\u5927\u7684\u4e0d\u540c\uff1a<\/p>\n\n\n\n<ul>\n<li><strong>\u7b80\u6d01\u6027<\/strong>\uff1aYAML \u66f4\u52a0\u7b80\u6d01\uff0c\u6ca1\u6709\u5197\u4f59\u7684\u6807\u7b7e\uff0c\u5bb9\u6613\u9605\u8bfb\u548c\u7f16\u8f91\u3002<\/li>\n\n\n\n<li><strong>\u6570\u636e\u6a21\u578b<\/strong>\uff1aXML \u5177\u6709\u66f4\u4e25\u683c\u7684\u5c42\u6b21\u7ed3\u6784\uff0c\u9002\u5408\u8868\u793a\u6811\u5f62\u6570\u636e\uff0c\u800c YAML \u66f4\u7075\u6d3b\uff0c\u9002\u5408\u8868\u793a\u5404\u79cd\u590d\u6742\u7684\u6570\u636e\u7ed3\u6784\u3002<\/li>\n\n\n\n<li><strong>\u89e3\u6790\u5668\u652f\u6301<\/strong>\uff1aXML \u7684\u89e3\u6790\u5668\u66f4\u4e3a\u6210\u719f\u548c\u5e7f\u6cdb\uff0c\u800c YAML \u7684\u89e3\u6790\u5668\u76f8\u5bf9\u8f83\u5c11\uff0c\u4f46\u5728\u73b0\u4ee3\u5e94\u7528\u4e2d\u5df2\u7ecf\u8db3\u591f\u4f7f\u7528\u3002<\/li>\n<\/ul>\n\n\n\n<p><strong>\u4f7f\u7528 YAML \u7684\u6ce8\u610f\u4e8b\u9879<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<ol>\n<li><strong>\u7f29\u8fdb\u4e00\u81f4\u6027<\/strong>\uff1a\u786e\u4fdd\u4f7f\u7528\u4e00\u81f4\u7684\u7f29\u8fdb\uff0c\u901a\u5e38\u662f\u4e24\u4e2a\u7a7a\u683c\uff0c\u907f\u514d\u4f7f\u7528\u5236\u8868\u7b26\u3002<\/li>\n\n\n\n<li><strong>\u7279\u6b8a\u5b57\u7b26\u8f6c\u4e49<\/strong>\uff1a\u5728\u5b57\u7b26\u4e32\u4e2d\u4f7f\u7528\u7279\u6b8a\u5b57\u7b26\u65f6\uff0c\u8003\u8651\u4f7f\u7528\u5f15\u53f7\u6216\u8f6c\u4e49\u5b57\u7b26\u3002<\/li>\n\n\n\n<li><strong>\u5e03\u5c14\u503c\u548c\u7a7a\u503c\u7684\u8868\u793a<\/strong>\uff1aYAML \u4e2d\u7684\u5e03\u5c14\u503c\u548c\u7a7a\u503c\u6709\u591a\u79cd\u8868\u793a\u65b9\u5f0f\uff0c\u9009\u62e9\u4e00\u79cd\u5e76\u4fdd\u6301\u4e00\u81f4\u3002<\/li>\n\n\n\n<li><strong>\u89e3\u6790\u5e93\u7684\u9009\u62e9<\/strong>\uff1a\u5728\u7f16\u7a0b\u4e2d\u4f7f\u7528 YAML \u65f6\uff0c\u9009\u62e9\u53ef\u9760\u7684\u89e3\u6790\u5e93\uff0c\u786e\u4fdd\u6b63\u786e\u5904\u7406 YAML \u7684\u6240\u6709\u7279\u6027\u3002<\/li>\n<\/ol>\n\n\n\n<p><strong>yaml \u6587\u4ef6\u4e2d, \u5bf9\u7f29\u8fdb\u51e0\u4e2a\u7a7a\u683c\u6709\u8981\u6c42\u5417<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u5728 YAML\uff08YAML Ain&#8217;t Markup Language\uff09\u6587\u4ef6\u91cc\uff0c\u7f29\u8fdb\u662f\u8868\u8fbe\u6570\u636e\u7ed3\u6784\u548c\u5c42\u6b21\u5173\u7cfb\u7684\u5173\u952e\u8981\u7d20\uff0c\u4e0d\u8fc7\u5e76\u6ca1\u6709\u5f3a\u5236\u89c4\u5b9a\u5177\u4f53\u7f29\u8fdb\u7684\u7a7a\u683c\u6570\u91cf\uff0c\u4e0d\u8fc7\u6709\u4e00\u4e9b\u901a\u7528\u7684\u89c4\u5219\u548c\u6700\u4f73\u5b9e\u8df5\u9700\u8981\u9075\u5faa\uff1a<\/p>\n\n\n\n<p><strong>\u901a\u7528\u89c4\u5219<\/strong><\/p>\n\n\n\n<ul>\n<li><strong>\u7f29\u8fdb\u5fc5\u987b\u4f7f\u7528\u7a7a\u683c<\/strong>\uff1a\u5728 YAML \u91cc\uff0c\u4e25\u7981\u4f7f\u7528\u5236\u8868\u7b26\uff08Tab\uff09\u8fdb\u884c\u7f29\u8fdb\uff0c\u8fd9\u662f\u56e0\u4e3a\u4e0d\u540c\u7684\u6587\u672c\u7f16\u8f91\u5668\u5bf9\u5236\u8868\u7b26\u7684\u663e\u793a\u5bbd\u5ea6\u5b58\u5728\u5dee\u5f02\uff0c\u53ef\u80fd\u4f1a\u5f15\u53d1\u89e3\u6790\u9519\u8bef\u3002\u56e0\u6b64\uff0c\u53ea\u80fd\u4f7f\u7528\u7a7a\u683c\u6765\u5b8c\u6210\u7f29\u8fdb\u3002<\/li>\n\n\n\n<li><strong>\u540c\u4e00\u5c42\u6b21\u7f29\u8fdb\u9700\u4fdd\u6301\u4e00\u81f4<\/strong>\uff1a\u5728\u540c\u4e00\u5c42\u7ea7\u7684\u5143\u7d20\uff0c\u5176\u7f29\u8fdb\u7684\u7a7a\u683c\u6570\u5fc5\u987b\u76f8\u540c\u3002\u6bd4\u5982\u4e0b\u9762\u8fd9\u4e2a\u4f8b\u5b50\uff1a<\/li>\n<\/ul>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">person:\n  name: John\n  age: 30\n  address:\n    city: New York\n    street: 123 Main St<\/pre>\n\n\n\n<p>\u5728<code>person<\/code>\u8fd9\u4e2a\u952e\u4e0b\u7684<code>name<\/code>\u3001<code>age<\/code>\u548c<code>address<\/code>\u5c5e\u4e8e\u540c\u4e00\u5c42\u7ea7\uff0c\u5b83\u4eec\u7684\u7f29\u8fdb\u662f\u4e00\u81f4\u7684\uff1b<code>address<\/code>\u4e0b\u7684<code>city<\/code>\u548c<code>street<\/code>\u4e5f\u662f\u540c\u4e00\u5c42\u7ea7\uff0c\u7f29\u8fdb\u540c\u6837\u4fdd\u6301\u4e00\u81f4\u3002<\/p>\n\n\n\n<p><strong>\u6700\u4f73\u5b9e\u8df5<\/strong><\/p>\n\n\n\n<ul>\n<li><strong>\u901a\u5e38\u91c7\u7528 2 \u4e2a\u6216 4 \u4e2a\u7a7a\u683c<\/strong>\uff1a\u5c3d\u7ba1 YAML \u6ca1\u6709\u786c\u6027\u89c4\u5b9a\u5177\u4f53\u7684\u7a7a\u683c\u6570\u91cf\uff0c\u4f46\u793e\u533a\u91cc\u8f83\u4e3a\u5e38\u89c1\u7684\u505a\u6cd5\u662f\u4f7f\u7528 2 \u4e2a\u6216 4 \u4e2a\u7a7a\u683c\u6765\u7f29\u8fdb\u30022 \u4e2a\u7a7a\u683c\u7684\u7f29\u8fdb\u80fd\u8ba9\u6587\u4ef6\u663e\u5f97\u66f4\u52a0\u7d27\u51d1\uff0c\u800c 4 \u4e2a\u7a7a\u683c\u7684\u7f29\u8fdb\u5219\u80fd\u8ba9\u5c42\u6b21\u7ed3\u6784\u66f4\u4e3a\u6e05\u6670\uff0c\u4fbf\u4e8e\u9605\u8bfb\u3002\u4f8b\u5982\uff1a<\/li>\n<\/ul>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># 2 \u4e2a\u7a7a\u683c\u7f29\u8fdb\u793a\u4f8b\nparent:\n  child1: value1\n  child2: value2\n\n# 4 \u4e2a\u7a7a\u683c\u7f29\u8fdb\u793a\u4f8b\nparent:\n    child1: value1\n    child2: value2<\/pre>\n\n\n\n<ul>\n<li><strong>\u4fdd\u6301\u6574\u4e2a\u6587\u4ef6\u7f29\u8fdb\u98ce\u683c\u7edf\u4e00<\/strong>\uff1a\u5728\u540c\u4e00\u4e2a YAML \u6587\u4ef6\u91cc\uff0c\u5efa\u8bae\u81ea\u59cb\u81f3\u7ec8\u91c7\u7528\u76f8\u540c\u6570\u91cf\u7684\u7a7a\u683c\u8fdb\u884c\u7f29\u8fdb\uff0c\u4ee5\u786e\u4fdd\u6587\u4ef6\u7684\u53ef\u8bfb\u6027\u548c\u4e00\u81f4\u6027\u3002\u8981\u662f\u5728\u6587\u4ef6\u91cc\u6df7\u7528\u4e0d\u540c\u6570\u91cf\u7684\u7a7a\u683c\u7f29\u8fdb\uff0c\u4f1a\u8ba9\u6587\u4ef6\u7ed3\u6784\u53d8\u5f97\u6df7\u4e71\uff0c\u589e\u52a0\u9605\u8bfb\u548c\u7ef4\u62a4\u7684\u96be\u5ea6\u3002<\/li>\n<\/ul>\n\n\n\n<p><strong>\u603b\u7ed3<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<p>\u672c\u6587\uff0c\u6211\u4eec\u8be6\u7ec6\u5206\u6790\u4e86 YAMl\u6587\u4ef6\u4ee5\u53ca\u548c\u4e00\u4e9b\u5e38\u89c1\u7684\u6587\u4ef6\u683c\u5f0f\u5bf9\u6bd4\uff0cYAML \u662f\u4e00\u79cd\u5f3a\u5927\u4e14\u7075\u6d3b\u7684\u6570\u636e\u5e8f\u5217\u5316\u683c\u5f0f\uff0c\u51ed\u501f\u5176\u7b80\u6d01\u548c\u53ef\u8bfb\u7684\u7279\u6027\uff0c\u6210\u4e3a\u8bb8\u591a\u5e94\u7528\u7684\u9996\u9009\u914d\u7f6e\u6587\u4ef6\u683c\u5f0f\u3002\u4f5c\u4e3a Java\u7a0b\u5e8f\u5458\uff0cYAML\u662f\u5f88\u591a\u9879\u76ee\u7684\u9996\u9009\uff0c\u56e0\u6b64\uff0c\u4e86\u89e3\u548c\u638c\u63e1\u5176\u57fa\u672c\u8bed\u6cd5\u548c\u7279\u6027\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u80fd\u66f4\u597d\u7684\u4f7f\u7528\u5b83\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8f6c\u8f7d\uff1aYAML\u6587\u4ef6\u6df1\u5ea6\u5206\u6790\uff01 YAML \u662f\u975e\u5e38\u6d41\u884c\u7684\u4e00\u79cd\u914d\u7f6e\u6587\u4ef6\u683c\u5f0f\uff0c\u65e0\u8bba\u662f\u524d\u7aef\u8fd8\u662f\u540e\u7aef\uff0c\u90fd\u53ef\u4ee5\u89c1\u5230 YAML [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[30],"tags":[],"_links":{"self":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/16473"}],"collection":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=16473"}],"version-history":[{"count":3,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/16473\/revisions"}],"predecessor-version":[{"id":17152,"href":"https:\/\/92it.top\/index.php?rest_route=\/wp\/v2\/posts\/16473\/revisions\/17152"}],"wp:attachment":[{"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=16473"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=16473"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/92it.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=16473"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}