{"id":4610,"date":"2022-03-27T14:12:49","date_gmt":"2022-03-27T06:12:49","guid":{"rendered":"https:\/\/egonlin.com\/?p=4610"},"modified":"2022-04-26T14:22:36","modified_gmt":"2022-04-26T06:22:36","slug":"%e7%ac%ac%e4%b8%89%e8%8a%82%ef%bc%9a%e4%bd%bf%e7%94%a8-maven-%e8%bf%9b%e8%a1%8c%e5%88%86%e7%8e%af%e5%a2%83%e9%85%8d%e7%bd%ae%e5%92%8c%e5%8f%91%e5%b8%83%e7%89%88%e6%9c%ac","status":"publish","type":"post","link":"https:\/\/egonlin.com\/?p=4610","title":{"rendered":"\u7b2c\u4e09\u8282\uff1a\u4f7f\u7528 Maven \u8fdb\u884c\u5206\u73af\u5883\u914d\u7f6e\u548c\u53d1\u5e03\u7248\u672c"},"content":{"rendered":"<h4>\u4f7f\u7528 Maven \u8fdb\u884c\u5206\u73af\u5883\u914d\u7f6e\u548c\u53d1\u5e03\u7248\u672c<\/h4>\n<p>\u9996\u5148\uff0c\u5728\u8bb2\u89e3 Maven \u7684\u7528\u6cd5\u7684\u65f6\u5019\uff0c\u6211\u4eec\u9700\u8981\u666e\u53ca\u4e0b\u9762\u7684\u4e00\u4e9b\u6982\u5ff5\uff1a<\/p>\n<p>\u5728\u516c\u53f8\uff0c\u6211\u4eec\u5e38\u89c1\u7684\u5e38\u7528\u7684\u73af\u5883\u6709\uff1adev\u3001sit\u3001pro, \u5177\u4f53\u7684\u4ecb\u7ecd\u5982\u4e0b\uff1a<\/p>\n<blockquote>\n<p>dev\u5c31\u662f\u5f00\u53d1\u73af\u5883(Development Environment)\uff0c\u6bcf\u4e2a\u5f00\u53d1\u4eba\u5458\u81ea\u5df1\u642d\u5efa\u7684\u73af\u5883\uff0c\u5f53\u7136\u4e00\u822c\u4e5f\u4f1a\u5728\u516c\u53f8\u5185\u90e8\u670d\u52a1\u5668\u642d\u5efa\u4e00\u4e9b\u8bf8\u5982\u6570\u636e\u5e93\u3001\u5206\u5e03\u5f0f\u670d\u52a1\u7b49\u516c\u7528\u7684\u5f00\u53d1\u73af\u5883\u670d\u52a1\u3002<\/p>\n<p>sit\u5c31\u662f\u7cfb\u7edf\u96c6\u6210\u6d4b\u8bd5\u73af\u5883(System Integration Testing Environment)\uff0c\u4e3b\u8981\u76ee\u7684\u662f\u628a\u7cfb\u7edf\u7684\u5404\u4e2a\u6a21\u5757\u4f5c\u4e3a\u4e00\u4e2a\u7ec4\u8fdb\u884c\u6d4b\u8bd5\u3002<\/p>\n<p>pro\u5c31\u662f\u751f\u4ea7\u73af\u5883(Production Environment)\uff0c\u8fd9\u4e2a\u73af\u5883\u662f\u6211\u4eec\u6700\u7ec8\u4ea4\u4ed8\u7684\u4ea7\u54c1\u6240\u8fd0\u884c\u7684\u73af\u5883\u3002<\/p>\n<\/blockquote>\n<p>\u4e3a\u4ec0\u4e48\u8981\u6709\u8fd9\u4e48\u591a\u73af\u5883\u5462\uff1f\u7b54\u6848\u662f\u5f62\u52bf\u6240\u8feb\u3002\u968f\u7740\u8f6f\u4ef6\u5f00\u53d1\u7684\u5206\u5de5\u65e5\u76ca\u7cbe\u7ec6\u5316\u548c\u8f6f\u4ef6\u7cfb\u7edf\u7684\u65e5\u76ca\u590d\u6742\u5316\uff0c\u4e0d\u540c\u73af\u5883\u6240\u627f\u62c5\u7684\u804c\u8d23\u4e0d\u540c\uff0c\u4f46\u6700\u7ec8\u76ee\u7684\u662f\u4e00\u6837\u7684\uff1a\u63d0\u9ad8\u6548\u7387\u3001\u4fdd\u8bc1\u8d28\u91cf\u3001\u8282\u7ea6\u6210\u672c\u3001\u4fdd\u8bc1\u6536\u76ca\u3002<\/p>\n<p>\u5173\u4e8e\u5206\u73af\u5883\u7684\u601d\u60f3\u8fd9\u91cc\u5c31\u4e0d\u591a\u8bb2\u4e86\uff0c\u4e0b\u9762\u8981\u8bb2\u7684\u4e00\u4e2a\u95ee\u9898\u662f\u5206\u73af\u5883\u662f\u5982\u4f55\u5b9e\u73b0\u7684\uff1f<br \/>\n\u5206\u73af\u5883\u7684\u5b9e\u73b0\u65b9\u5f0f\u6709\u5f88\u591aSpring Profile\u3001Spring Boot\u7b49\u7b49\u90fd\u6709\u4e0d\u540c\u7684\u5b9e\u73b0\u3002<\/p>\n<p>\u4e0b\u9762\u8bb2\u4e00\u4e2a\u4f7f\u7528 maven profiles \u5b9e\u73b0\u5206\u73af\u5883\u914d\u7f6e\u7684\u65b9\u5f0f\u3002<\/p>\n<h4>\u5206\u73af\u5883\u5b9e\u73b0<\/h4>\n<p>\u6bd4\u5982\u6211\u5728\u4e0d\u540c\u7684\u73af\u5883\u9700\u8981\u63d0\u4f9b\u4e0d\u540c\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u600e\u4e48\u5b9e\u73b0\u5462\uff1f<\/p>\n<p>\u9996\u5148\u5728pom.xml\u589e\u52a0\u5982\u4e0b\u51e0\u4e2a\u73af\u5883\u7684\u914d\u7f6e\uff0c\u5e76\u6307\u5b9a\u914d\u7f6e\u8def\u5f84\uff1a<\/p>\n<pre><code class=\"language-xml\">&lt;profiles&gt;\n\n    &lt;!-- \u5206\u73af\u5883profile&gt; --&gt;\n    &lt;profile&gt;\n        &lt;id&gt;dev&lt;\/id&gt;\n        &lt;!-- \u5982\u679cdev\u5e26\u4e0aactiveByDefault\uff0c\u4f1a\u9ed8\u8ba4\u5c06dev\u4e0b\u7684\u914d\u7f6e\u590d\u5236\u5230config\u76ee\u5f55\u4e0b--&gt;\n        &lt;activation&gt;\n            &lt;activeByDefault&gt;true&lt;\/activeByDefault&gt;\n        &lt;\/activation&gt;\n        &lt;properties&gt;\n            &lt;env&gt;dev&lt;\/env&gt;\n            &lt;package.target&gt;dev&lt;\/package.target&gt;\n            &lt;spring.profiles.active.value&gt;dev&lt;\/spring.profiles.active.value&gt;\n            &lt;yui.skip&gt;true&lt;\/yui.skip&gt;\n            &lt;config.path&gt;src\/main\/resources\/config\/dev&lt;\/config.path&gt;\n        &lt;\/properties&gt;\n    &lt;\/profile&gt;\n\n    &lt;!--sit--&gt;\n    &lt;profile&gt;\n        &lt;id&gt;sit&lt;\/id&gt;\n        &lt;properties&gt;\n            &lt;env&gt;sit&lt;\/env&gt;\n            &lt;package.target&gt;sit&lt;\/package.target&gt;\n            &lt;spring.profiles.active.value&gt;sit&lt;\/spring.profiles.active.value&gt;\n            &lt;yui.skip&gt;false&lt;\/yui.skip&gt;\n            &lt;config.path&gt;src\/main\/resources\/config\/sit&lt;\/config.path&gt;\n        &lt;\/properties&gt;\n    &lt;\/profile&gt;\n\n    &lt;!-- uat --&gt;\n    &lt;profile&gt;\n        &lt;id&gt;uat&lt;\/id&gt;\n        &lt;properties&gt;\n            &lt;env&gt;uat&lt;\/env&gt;\n            &lt;package.target&gt;uat&lt;\/package.target&gt;\n            &lt;spring.profiles.active.value&gt;uat&lt;\/spring.profiles.active.value&gt;\n            &lt;yui.skip&gt;false&lt;\/yui.skip&gt;\n            &lt;config.path&gt;src\/main\/resources\/config\/uat&lt;\/config.path&gt;\n        &lt;\/properties&gt;\n    &lt;\/profile&gt;\n\n    &lt;!--sandbox--&gt;\n    &lt;profile&gt;\n        &lt;id&gt;sandbox&lt;\/id&gt;\n        &lt;properties&gt;\n            &lt;env&gt;sandbox&lt;\/env&gt;\n            &lt;package.target&gt;sandbox&lt;\/package.target&gt;\n            &lt;spring.profiles.active.value&gt;sandbox&lt;\/spring.profiles.active.value&gt;\n            &lt;yui.skip&gt;false&lt;\/yui.skip&gt;\n            &lt;config.path&gt;src\/main\/resources\/config\/sandbox&lt;\/config.path&gt;\n        &lt;\/properties&gt;\n    &lt;\/profile&gt;\n\n    &lt;!--prod--&gt;\n    &lt;profile&gt;\n        &lt;id&gt;prod&lt;\/id&gt;\n        &lt;properties&gt;\n            &lt;env&gt;prod&lt;\/env&gt;\n            &lt;package.target&gt;prod&lt;\/package.target&gt;\n            &lt;spring.profiles.active.value&gt;prod&lt;\/spring.profiles.active.value&gt;\n            &lt;yui.skip&gt;false&lt;\/yui.skip&gt;\n            &lt;config.path&gt;src\/main\/resources\/config\/prod&lt;\/config.path&gt;\n        &lt;\/properties&gt;\n    &lt;\/profile&gt;\n\n&lt;\/profiles&gt;<\/code><\/pre>\n<p>\u7136\u540e\u5728\u6253\u5305\u9879\u76ee\u7684\u65f6\u5019\u901a\u8fc7-P\u53c2\u6570\u6307\u5b9a\u73af\u5883\u5c31\u884c\u4e86\u3002\u4f8b\u5982\u6253\u5305 prod \u73af\u5883\uff1a<\/p>\n<blockquote>\n<p>mvn install -Puat<\/p>\n<\/blockquote>\n<h4>\u6307\u5b9a\u73af\u5883\u6253\u5305\u7684\u7f3a\u70b9<\/h4>\n<p>\u9996\u5148\u5c31\u662f\u6162\uff0c\u4e5f\u53ef\u8bf4\u6d6a\u8d39\u5496\u5561\u3002\u5f88\u591a\u5927\u578b\u9879\u76ee\u6bcf\u6b21\u4ece\u7f16\u8bd1\u5230\u62c9\u6587\u4ef6\u90fd\u8981\u534a\u4e2a\u591a\u5c0f\u65f6\u3002<br \/>\n\u90a3\u600e\u4e48\u8282\u7701\u53d1\u5e03\u7684\u65f6\u95f4\uff0c\u8ba9\u6211\u4eec\u65e9\u70b9\u4e0b\u73ed\u5462\uff1f<br \/>\n\u7b54\u6848\u5c31\u662f\u6240\u6709\u73af\u5883\u4e00\u4e2a\u5305\u3002<br \/>\n5\u4e2a\u73af\u5883\u5c31\u80fd\u8282\u77012\u4e2a\u5c0f\u65f6\uff0c\u592a\u503c\u4e86\uff01\u56e0\u4e3a\u6700\u7ec8\u53ea\u6253\u4e00\u4e2a\u5305<\/p>\n<h4>\u5c06\u6240\u6709\u73af\u5883\u6253\u6210\u4e00\u4e2a\u5305<\/h4>\n<p><\/p><div id=\"rml_readmorelogin_placeholder\" style=\"position:relative;\"><div id=\"rml_fade_content\" style=\"position: absolute;\r\ntop:-10em;\r\nwidth:100%;\r\nheight:10em;\r\nbackground: -webkit-linear-gradient(rgba(255, 255, 255, 0) 0%,#ffffff 100%);\r\nbackground-image: -moz-linear-gradient(rgba(255, 255, 255, 0) 0%,#ffffff 100%);\r\nbackground-image: -o-linear-gradient(rgba(255, 255, 255, 0) 0%,#ffffff 100%);\r\nbackground-image: linear-gradient(rgba(255, 255, 255, 0) 0%,#ffffff 100%);\r\nbackground-image: -ms-linear-gradient(rgba(255, 255, 255, 0) 0%,#ffffff 100%);\"><\/div><div class=\"wpf-controller aru_rml_from_in_post\" style=\"background-color:#eeeeee;border:5px solid #cce6ff;\" id=\"ARU_ReadMoreLogin_ReadMoreLoginController\"><h2 id=\"Header\">\u67e5\u770b\u66f4\u591a<\/h2><div id=\"Message\"><p>\u8054\u7cfb\u7ba1\u7406\u5458\u5fae\u4fe1tutu19192010\uff0c\u6ce8\u518c\u8d26\u53f7<\/p>\n<\/div><div id=\"StatusBarHeader\"><\/div><form id=\"ARU_ReadMoreLogin_ReadMoreLoginController\"><input name=\"post_id\" value=\"4610\" type=\"hidden\"\/><input name=\"_init_callback\" value=\"InitLogin\" type=\"hidden\"\/><input name=\"post_id\" value=\"4610\" type=\"hidden\"\/><input name=\"rt_ype\" value=\"1\" type=\"hidden\"\/><input name=\"nonce\" value=\"7f2c7bdf95\" type=\"hidden\"\/><input name=\"_wpnonce\" value=\"55208fda31\" type=\"hidden\"\/><input name=\"_controller\" value=\"ARU_ReadMoreLogin\\ReadMoreLoginController\" type=\"hidden\"\/><input name=\"_proxy_controller\" value=\"ARU_ReadMoreLogin\\ReadMoreLoginController\" type=\"hidden\"\/><input name=\"_view\" value=\"ARU_ReadMoreLogin\\ReadMoreLoginView\" type=\"hidden\"\/><table class=\"wpf-table-placeholder\"><tbody class=\"wpf-table-placeholder\"><tr class=\"wpf-table-placeholder\"><td class=\"wpf-table-placeholder-input\" width=\"400px\"><table class=\"wpf-table-placeholder\"><tbody class=\"wpf-table-placeholder\"><tr class=\"wpf-table-placeholder\"><th class=\"wpf-table-placeholder-input\"><label class=\"wpf-label\">Username:<\/label><\/th><\/tr><tr class=\"wpf-table-placeholder\"><td class=\"wpf-table-placeholder-input\"><input class=\"regular-text text_input\" name=\"username\" value=\"\" type=\"text\"\/><\/td><\/tr><tr class=\"wpf-table-placeholder\"><th class=\"wpf-table-placeholder-input\"><label class=\"wpf-label\">Password:<\/label><\/th><\/tr><tr class=\"wpf-table-placeholder\"><td class=\"wpf-table-placeholder-input\"><input class=\"regular-text text_input\" name=\"password\" value=\"\" type=\"password\"\/><\/td><\/tr><\/tbody><\/table><p class=\"wpf-table-placeholder submit\"><button class=\"wp_plugin_framework_ajax_button\" type=\"button\" style=\"background-color:#4D90FE;;color:#ffffff;;border:1px solid #3079ed;\" name=\"_event\" value=\"ButtonLogin\">Log in<\/button><\/p><\/td><td class=\"wpf-table-placeholder-input\"><\/td><\/tr><\/tbody><\/table><\/form><div id=\"ButtonStartRegister\"><a href=\"https:\/\/egonlin.com\/wp-login.php?action=register\">Register<\/a><\/div><div id=\"Link1\"><a href=\"https:\/\/egonlin.com\/wp-login.php?action=lostpassword\">Forgotten username or password?<\/a><\/div><div id=\"StatusBarFooter\"><\/div><\/div><\/div><div id=aru_remaining_content><\/div>","protected":false},"excerpt":{"rendered":"<p>\u4f7f\u7528 Maven \u8fdb\u884c\u5206\u73af\u5883\u914d\u7f6e\u548c\u53d1\u5e03\u7248\u672c \u9996\u5148\uff0c\u5728\u8bb2\u89e3 Maven \u7684\u7528\u6cd5\u7684\u65f6\u5019\uff0c\u6211\u4eec\u9700\u8981\u666e\u53ca\u4e0b\u9762\u7684\u4e00\u4e9b\u6982\u5ff5 [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[353,351],"tags":[],"_links":{"self":[{"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/posts\/4610"}],"collection":[{"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/egonlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4610"}],"version-history":[{"count":0,"href":"https:\/\/egonlin.com\/index.php?rest_route=\/wp\/v2\/posts\/4610\/revisions"}],"wp:attachment":[{"href":"https:\/\/egonlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4610"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/egonlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4610"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/egonlin.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4610"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}