{"id":203158,"date":"2025-05-22T10:29:52","date_gmt":"2025-05-22T02:29:52","guid":{"rendered":"https:\/\/server.hk\/cnblog\/203158\/"},"modified":"2025-05-22T10:29:52","modified_gmt":"2025-05-22T02:29:52","slug":"spring-boot-%e9%a1%b9%e7%9b%ae%e6%89%93%e5%8c%85%e6%97%b6%e6%97%a0%e6%b3%95%e5%8c%85%e5%90%ab-application-properties-%e6%96%87%e4%bb%b6%ef%bc%8c%e6%98%af%e4%bb%80%e4%b9%88%e5%8e%9f%e5%9b%a0%e5%af%bc","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/203158\/","title":{"rendered":"Spring Boot \u9879\u76ee\u6253\u5305\u65f6\u65e0\u6cd5\u5305\u542b application.properties \u6587\u4ef6\uff0c\u662f\u4ec0\u4e48\u539f\u56e0\u5bfc\u81f4\u7684\uff1f"},"content":{"rendered":"<p><b><\/b>     <\/p>\n<h1>Spring Boot \u9879\u76ee\u6253\u5305\u65f6\u65e0\u6cd5\u5305\u542b application.properties \u6587\u4ef6\uff0c\u662f\u4ec0\u4e48\u539f\u56e0\u5bfc\u81f4\u7684\uff1f<\/h1>\n<p>\u672c\u7bc7\u6587\u7ae0\u7ed9\u5927\u5bb6\u5206\u4eab\u300aSpring Boot \u9879\u76ee\u6253\u5305\u65f6\u65e0\u6cd5\u5305\u542b application.properties \u6587\u4ef6\uff0c\u662f\u4ec0\u4e48\u539f\u56e0\u5bfc\u81f4\u7684\uff1f\u300b\uff0c\u8986\u76d6\u4e86\u6587\u7ae0\u7684\u5e38\u89c1\u57fa\u7840\u77e5\u8bc6\uff0c\u5176\u5b9e\u4e00\u4e2a\u8bed\u8a00\u7684\u5168\u90e8\u77e5\u8bc6\u70b9\u4e00\u7bc7\u6587\u7ae0\u662f\u4e0d\u53ef\u80fd\u8bf4\u5b8c\u7684\uff0c\u4f46\u5e0c\u671b\u901a\u8fc7\u8fd9\u4e9b\u95ee\u9898\uff0c\u8ba9\u8bfb\u8005\u5bf9\u81ea\u5df1\u7684\u638c\u63e1\u7a0b\u5ea6\u6709\u4e00\u5b9a\u7684\u8ba4\u8bc6(B \u6570)\uff0c\u4ece\u800c\u5f25\u8865\u81ea\u5df1\u7684\u4e0d\u8db3\uff0c\u66f4\u597d\u7684\u638c\u63e1\u5b83\u3002<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241030\/17302776016721f0e1a36dd.jpg\" class=\"aligncenter\"><\/p>\n<p><strong>\u65e0\u6cd5\u6253\u5305\u7684\u539f\u56e0\u5206\u6790<\/strong><\/p>\n<p>\u5728 spring boot \u9879\u76ee\u4e2d\uff0capplication.properties \u6587\u4ef6\u5e94\u4f4d\u4e8e src\/main\/resources \u76ee\u5f55\u4e0b\u3002\u5982\u679c\u5b83\u4f4d\u4e8e\u5176\u4ed6\u4f4d\u7f6e\uff0c\u4f8b\u5982 src\/main\/java \u6216\u5176\u4ed6\u76ee\u5f55\uff0c\u5219 maven \u5728\u6253\u5305\u65f6\u5c06\u65e0\u6cd5\u5c06\u5176\u5305\u542b\u5728 target \u76ee\u5f55\u4e2d\u3002<\/p>\n<p>\u6b64\u5916\uff0c\u8bf7\u786e\u4fdd\u5e94\u7528\u7a0b\u5e8f\u914d\u7f6e\u6587\u4ef6\u7684\u540d\u79f0\u6b63\u786e\u3002\u5982\u679c\u4f7f\u7528\u7684\u662f yaml \u683c\u5f0f\uff0c\u5219\u5e94\u4f7f\u7528 application.yml\uff0c\u5982\u679c\u4f7f\u7528\u7684\u662f\u5c5e\u6027\u683c\u5f0f\uff0c\u5219\u5e94\u4f7f\u7528 application.properties\u3002<\/p>\n<p><strong>pom.xml \u4e2d\u8d44\u6e90\u914d\u7f6e<\/strong><\/p>\n<p>\u5728 pom.xml \u6587\u4ef6\u4e2d\uff0c\u9700\u8981\u6b63\u786e\u914d\u7f6e\u8d44\u6e90\u8fc7\u6ee4\uff0c\u4ee5\u786e\u4fdd\u914d\u7f6e\u6587\u4ef6\u88ab\u8bc6\u522b\u548c\u6253\u5305\u3002\u4ee5\u4e0b\u662f\u6b63\u786e\u7684\u914d\u7f6e\uff1a<\/p>\n<pre>&lt;build&gt;\n    &lt;resources&gt;\n        &lt;resource&gt;\n            &lt;directory&gt;src\/main\/resources&lt;\/directory&gt;\n            &lt;filtering&gt;true&lt;\/filtering&gt;\n        &lt;\/resource&gt;\n    &lt;\/resources&gt;\n&lt;\/build&gt;<\/pre>\n<p>\u8be5\u914d\u7f6e\u5c06\u542f\u7528\u5bf9 src\/main\/resources \u76ee\u5f55\u4e0b\u6240\u6709\u6587\u4ef6\u7684\u8fc7\u6ee4\uff0c\u5305\u62ec application.properties\uff0c\u4f7f\u5176\u5728\u6253\u5305\u65f6\u88ab\u6b63\u786e\u8bc6\u522b\u548c\u5305\u542b\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u300aSpring Boot \u9879\u76ee\u6253\u5305\u65f6\u65e0\u6cd5\u5305\u542b application.properties \u6587\u4ef6\uff0c\u662f\u4ec0\u4e48\u539f\u56e0\u5bfc\u81f4\u7684\uff1f\u300b\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u5173\u4e8e\u7684\u8d44\u6599\u8bf7\u5173\u6ce8\u516c\u4f17\u53f7\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Spring Boot \u9879\u76ee\u6253\u5305&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4925],"tags":[],"class_list":["post-203158","post","type-post","status-publish","format-standard","hentry","category-4925"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/203158","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=203158"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/203158\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=203158"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=203158"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=203158"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}