{"id":1656,"date":"2026-04-24T09:49:55","date_gmt":"2026-04-24T01:49:55","guid":{"rendered":"https:\/\/blog.ttwow.top\/?p=1656"},"modified":"2026-06-19T21:14:59","modified_gmt":"2026-06-19T13:14:59","slug":"windows%e4%b8%8a%e6%89%93%e5%8c%85springboot%e9%a1%b9%e7%9b%ae%e8%84%9a%e6%9c%ac","status":"publish","type":"post","link":"https:\/\/blog.ttwow.top\/?p=1656","title":{"rendered":"windows\u4e0a\u6253\u5305springboot\u9879\u76ee\u811a\u672c"},"content":{"rendered":"<pre><code class=\"language-shell\">@echo off\nchcp 65001 &gt;nul\nsetlocal EnableDelayedExpansion\n\n:: \u8bbe\u7f6e\u8def\u5f84\nset &quot;projectDir=D:\\Code\\XXXX&quot;\nset &quot;yamlPath=XXXX\\src\\main\\resources\\application.yaml&quot;\nset &quot;yamlFile=%projectDir%\\%yamlPath%&quot;\n\n:: \u5173\u952e\uff1a\u5c06\u5907\u4efd\u6587\u4ef6\u653e\u5728\u6839\u76ee\u5f55\uff0c\u9632\u6b62\u88ab Maven \u626b\u63cf\u6253\u5305\nset &quot;bakFile=%projectDir%\\application.yaml.bak&quot;\nset &quot;tmpFile=%projectDir%\\application.yaml.tmp&quot;\n\necho ==============================\necho   \u8bf7\u9009\u62e9\u8fd0\u884c\u73af\u5883\uff1a\necho   1. prod\necho   2. test\necho   3. local\necho   4. prod-test\necho ==============================\n\nset \/p choice=\u8bf7\u8f93\u5165\u9009\u9879(1-4)\uff1a \n\nif &quot;%choice%&quot;==&quot;1&quot; set &quot;profile=prod&quot;\nif &quot;%choice%&quot;==&quot;2&quot; set &quot;profile=test&quot;\nif &quot;%choice%&quot;==&quot;3&quot; set &quot;profile=local&quot;\nif &quot;%choice%&quot;==&quot;4&quot; set &quot;profile=prod-test&quot;\n\nif not defined profile (\n    echo \u65e0\u6548\u8f93\u5165\n    pause\n    exit \/b 1\n)\n\necho \u5f53\u524d\u73af\u5883: %profile%\n\n:: 1. \u5907\u4efd\u5230\u6839\u76ee\u5f55\ncopy \/y &quot;%yamlFile%&quot; &quot;%bakFile%&quot; &gt;nul\n\necho \u5f00\u59cb\u4fee\u6539 YAML...\n\n:: 2. \u4fee\u6539 active \u884c\n(for \/f &quot;tokens=1* delims=:&quot; %%a in (&#039;findstr \/n \/r &quot;^&quot; &quot;%bakFile%&quot;&#039;) do (\n    set &quot;line=%%b&quot;\n    if defined line (\n        set &quot;trimmed=!line!&quot;\n        :: \u53bb\u6389\u884c\u9996\u7a7a\u683c\u8fdb\u884c\u524d\u7f00\u5339\u914d\n        for \/f &quot;tokens=*&quot; %%g in (&quot;!line!&quot;) do set &quot;trimmed=%%g&quot;\n\n        :: \u68c0\u67e5\u662f\u5426\u4ee5 active: \u5f00\u5934\n        if &quot;!trimmed:~0,7!&quot;==&quot;active:&quot; (\n            :: \u8fd9\u91cc\u8bbe\u7f6e\u7f29\u8fdb\uff1a4\u4e2a\u7a7a\u683c\u4ee3\u8868 2 \u4e2a Tab \u7684\u89c6\u89c9\u4f4d\u7f6e\n            echo     active: %profile%\n        ) else (\n            echo(!line!\n        )\n    ) else (\n        echo.\n    )\n)) &gt; &quot;%tmpFile%&quot;\n\n:: \u8986\u76d6\u539f\u6587\u4ef6\nmove \/y &quot;%tmpFile%&quot; &quot;%yamlFile%&quot; &gt;nul\n\necho \u5f00\u59cb\u6253\u5305...\ncd \/d &quot;%projectDir%&quot;\n:: \u4f7f\u7528 call \u786e\u4fdd mvn \u6267\u884c\u5b8c\u540e\u80fd\u56de\u5230\u672c\u811a\u672c\u7ee7\u7eed\u6267\u884c\u6062\u590d\u903b\u8f91\ncall mvn clean package -DskipTests\n\n:: 3. \u6062\u590d\u914d\u7f6e\u6587\u4ef6\u5e76\u5220\u9664\u5907\u4efd\necho \u6b63\u5728\u6062\u590d\u914d\u7f6e\u6587\u4ef6...\nmove \/y &quot;%bakFile%&quot; &quot;%yamlFile%&quot; &gt;nul\n\necho ==============================\necho \u2714 \u6253\u5305\u5b8c\u6210\uff08.bak\u6587\u4ef6\u5df2\u81ea\u52a8\u6e05\u7406\uff09\necho ==============================\n\npause<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>@echo off chcp 65001 &gt;nul setlocal EnableDelayedExpa [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[135],"tags":[163],"class_list":["post-1656","post","type-post","status-publish","format-standard","hentry","category-code-snippets","tag-163"],"_links":{"self":[{"href":"https:\/\/blog.ttwow.top\/index.php?rest_route=\/wp\/v2\/posts\/1656","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ttwow.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ttwow.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ttwow.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ttwow.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1656"}],"version-history":[{"count":2,"href":"https:\/\/blog.ttwow.top\/index.php?rest_route=\/wp\/v2\/posts\/1656\/revisions"}],"predecessor-version":[{"id":1658,"href":"https:\/\/blog.ttwow.top\/index.php?rest_route=\/wp\/v2\/posts\/1656\/revisions\/1658"}],"wp:attachment":[{"href":"https:\/\/blog.ttwow.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1656"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ttwow.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1656"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ttwow.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1656"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}