{"id":8052,"date":"2023-11-28T20:12:29","date_gmt":"2023-11-28T12:12:29","guid":{"rendered":"https:\/\/wx.kaifamiao.info\/?p=8052"},"modified":"2023-12-05T16:07:50","modified_gmt":"2023-12-05T08:07:50","slug":"springboot-he-xin-pei-zhi-wen-jian-shi-shen-me-boo","status":"publish","type":"post","link":"http:\/\/wx.kaifamiao.info\/index.php\/2023\/11\/28\/springboot-he-xin-pei-zhi-wen-jian-shi-shen-me-boo\/","title":{"rendered":"SpringBoot \u6838\u5fc3\u914d\u7f6e\u6587\u4ef6\u662f\u4ec0\u4e48\uff1f bootstrap.properties \u548c application.properties \u6709\u4f55\u533a\u522b?"},"content":{"rendered":"<p>\u5728 Spring Boot \u4e2d\uff0c\u6709\u4e24\u4e2a\u4e3b\u8981\u7684\u914d\u7f6e\u6587\u4ef6\uff1a<code>bootstrap.properties<\/code> \u548c <code>application.properties<\/code>\uff08\u6216 <code>application.yml<\/code>\uff09\u3002\u5b83\u4eec\u5206\u522b\u7528\u4e8e\u4e0d\u540c\u7684\u914d\u7f6e\u76ee\u7684\u3002<\/p>\n<ol>\n<li>\n<strong><code>bootstrap.properties<\/code>\uff1a<\/strong><\/p>\n<ul>\n<li>\u8fd9\u662f Spring Boot \u7684\u5916\u90e8\u914d\u7f6e\u6587\u4ef6\u4e4b\u4e00\uff0c\u7528\u4e8e\u5728 Spring \u5e94\u7528\u7a0b\u5e8f\u542f\u52a8\u65f6\u8fdb\u884c\u7279\u6b8a\u7684\u8bbe\u7f6e\u3002<code>bootstrap.properties<\/code> \u4e2d\u7684\u914d\u7f6e\u9879\u901a\u5e38\u7528\u4e8e\u914d\u7f6e Spring Cloud\u3001Spring Cloud Config \u7b49\u4e0e\u5e94\u7528\u7a0b\u5e8f\u542f\u52a8\u76f8\u5173\u7684\u914d\u7f6e\u3002\u8fd9\u4e2a\u6587\u4ef6\u901a\u5e38\u7528\u4e8e\u914d\u7f6e\u4e00\u4e9b\u5728\u5e94\u7528\u7a0b\u5e8f\u542f\u52a8\u4e4b\u524d\u5c31\u9700\u8981\u52a0\u8f7d\u7684\u914d\u7f6e\u4fe1\u606f\uff0c\u4f8b\u5982\u914d\u7f6e\u4e2d\u5fc3\u7684\u5730\u5740\u3001\u52a0\u5bc6\u89e3\u5bc6\u7684\u5bc6\u94a5\u7b49\u3002<\/li>\n<li>\u4e0e <code>application.properties<\/code> \u4e0d\u540c\uff0c<code>bootstrap.properties<\/code> \u4e2d\u7684\u914d\u7f6e\u9879\u5728 Spring Boot \u542f\u52a8\u65f6\u9996\u5148\u88ab\u52a0\u8f7d\u3002\u8fd9\u6837\u53ef\u4ee5\u786e\u4fdd\u5728\u5e94\u7528\u7a0b\u5e8f\u7684\u5176\u4ed6\u914d\u7f6e\u9879\u52a0\u8f7d\u4e4b\u524d\uff0c\u8fd9\u4e9b\u914d\u7f6e\u9879\u5df2\u7ecf\u51c6\u5907\u5c31\u7eea\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\n<strong><code>application.properties<\/code> \u6216 <code>application.yml<\/code>\uff1a<\/strong><\/p>\n<ul>\n<li>\u8fd9\u662f Spring Boot \u5e94\u7528\u7a0b\u5e8f\u7684\u4e3b\u8981\u914d\u7f6e\u6587\u4ef6\uff0c\u7528\u4e8e\u5b9a\u4e49\u5e94\u7528\u7a0b\u5e8f\u7684\u5e38\u89c4\u914d\u7f6e\uff0c\u4f8b\u5982\u6570\u636e\u5e93\u8fde\u63a5\u3001\u670d\u52a1\u5668\u7aef\u53e3\u3001\u65e5\u5fd7\u7ea7\u522b\u7b49\u3002<code>application.properties<\/code> \u53ef\u4ee5\u4f7f\u7528\u4f20\u7edf\u7684 <code>.properties<\/code> \u6587\u4ef6\u683c\u5f0f\uff0c\u800c <code>application.yml<\/code> \u4f7f\u7528 YAML \u683c\u5f0f\uff0c\u5177\u6709\u66f4\u4eba\u7c7b\u53ef\u8bfb\u7684\u8bed\u6cd5\u3002<\/li>\n<li><code>application.properties<\/code> \u4e2d\u7684\u914d\u7f6e\u9879\u5728 <code>bootstrap.properties<\/code> \u52a0\u8f7d\u540e\u88ab\u52a0\u8f7d\uff0c\u5b83\u5305\u542b\u4e86\u5e94\u7528\u7a0b\u5e8f\u8fd0\u884c\u65f6\u6240\u9700\u7684\u4e3b\u8981\u914d\u7f6e\u4fe1\u606f\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><strong>\u533a\u522b\uff1a<\/strong><\/p>\n<ul>\n<li><code>bootstrap.properties<\/code> \u4e3b\u8981\u7528\u4e8e\u914d\u7f6e\u4e0e Spring Cloud \u76f8\u5173\u7684\u914d\u7f6e\u9879\uff0c\u5b83\u5728\u5e94\u7528\u7a0b\u5e8f\u542f\u52a8\u4e4b\u524d\u88ab\u52a0\u8f7d\u3002<\/li>\n<li><code>application.properties<\/code> \u6216 <code>application.yml<\/code> \u7528\u4e8e\u4e00\u822c\u7684\u5e94\u7528\u7a0b\u5e8f\u914d\u7f6e\uff0c\u8fd9\u4e9b\u914d\u7f6e\u9879\u5728 <code>bootstrap.properties<\/code> \u4e4b\u540e\u88ab\u52a0\u8f7d\u3002<\/li>\n<\/ul>\n<p>\u5728\u5b9e\u9645\u5e94\u7528\u4e2d\uff0c\u4f60\u53ef\u80fd\u4f1a\u4f7f\u7528 <code>application.properties<\/code> \u6216 <code>application.yml<\/code> \u66f4\u9891\u7e41\uff0c\u800c <code>bootstrap.properties<\/code> \u901a\u5e38\u7528\u4e8e\u7279\u6b8a\u7684\u914d\u7f6e\u9700\u6c42\uff0c\u4f8b\u5982\u914d\u7f6e\u4e2d\u5fc3\u7684\u5730\u5740\u7b49\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728 Spring Boot \u4e2d\uff0c\u6709\u4e24\u4e2a\u4e3b\u8981\u7684\u914d\u7f6e\u6587\u4ef6\uff1abootstrap.properties \u548c appli [&hellip;]<\/p>\n","protected":false},"author":9,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[100],"tags":[],"class_list":["post-8052","post","type-post","status-publish","format-standard","hentry","category-springboot"],"_links":{"self":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/8052","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/comments?post=8052"}],"version-history":[{"count":2,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/8052\/revisions"}],"predecessor-version":[{"id":16566,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/8052\/revisions\/16566"}],"wp:attachment":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/media?parent=8052"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/categories?post=8052"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/tags?post=8052"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}