{"id":533,"date":"2008-09-28T00:00:00","date_gmt":"2008-09-27T16:00:00","guid":{"rendered":"http:\/\/www.strongd.net\/?p=533"},"modified":"2011-07-15T09:14:39","modified_gmt":"2011-07-15T01:14:39","slug":"maven%e5%85%a5%e9%97%a8-%e6%a6%82%e5%bf%b5%e4%b8%8e%e5%ae%9e%e4%be%8b","status":"publish","type":"post","link":"https:\/\/www.strongd.net\/?p=533","title":{"rendered":"Maven\u5165\u95e8&#8211;\u6982\u5ff5\u4e0e\u5b9e\u4f8b"},"content":{"rendered":"<p><DIV><br \/>\n<DIV align=center><FONT size=4><STRONG>Maven\u5165\u95e8&#8211;\u6982\u5ff5\u4e0e\u5b9e\u4f8b<\/STRONG> <\/FONT><BR><\/DIV>&nbsp;&nbsp;&nbsp; \u6700\u8fd1\u7531\u4e8e\u5de5\u4f5c\u539f\u56e0\u5728\u7814\u7a76\u3001\u5e94\u7528Maven\uff0c\u6709\u4e86\u4e00\u4e9b\u4f53\u4f1a\u5c31\u5199\u6210\u4e86\u6b64\u6587\u3002\u672c\u6587\u867d\u7136\u662fMaven2\u7684\u5165\u95e8\u6587\u7ae0\uff0c\u4f46\u5e76\u4e0d\u6d89\u53caMaven\u7684\u5386\u53f2\u3001\u4e0b\u8f7d\u4e0e\u5b89\u88c5\uff0c\u8fd9\u4e9b\u5185\u5bb9\u53ef\u4ee5\u5230Maven\u7684\u5b98\u65b9\u7f51\u7ad9\u4e0a\u4e86\u89e3\u3002\u672c\u6587\u4e3b\u8981\u662f\u5173\u6ce8Maven\u4e2d\u7684\u91cd\u8981\u6982\u5ff5\uff0c\u5e76\u4ee5\u4e00\u4e2a\u5b9e\u4f8b\u6765\u9610\u8ff0\u4f7f\u7528Maven\u7684\u57fa\u672c\u65b9\u6cd5\u3002<STRONG>\u6587\u672b\u6709\u4f8b\u5b50\u4ee3\u7801\u4e0b\u8f7d\u7684\u94fe\u63a5<\/STRONG>\u3002(2007.01.02\u6700\u540e\u66f4\u65b0) <BR><STRONG>1 \u5173\u952e\u540d\u8bcd<\/STRONG> <BR>&nbsp;&nbsp;&nbsp; <STRONG>Project<\/STRONG>\uff1a\u4efb\u4f55\u60a8\u60f3build\u7684\u4e8b\u7269\uff0cMaven\u90fd\u53ef\u4ee5\u8ba4\u4e3a\u5b83\u4eec\u662f\u5de5\u7a0b\u3002\u8fd9\u4e9b\u5de5\u7a0b\u88ab\u5b9a\u4e49\u4e3a\u5de5\u7a0b\u5bf9\u8c61\u6a21\u578b(POM\uff0cPoject Object Model)\u3002\u4e00\u4e2a\u5de5\u7a0b\u53ef\u4ee5\u4f9d\u8d56\u5176\u5b83\u7684\u5de5\u7a0b\uff1b\u4e00\u4e2a\u5de5\u7a0b\u4e5f\u53ef\u4ee5\u7531\u591a\u4e2a\u5b50\u5de5\u7a0b\u6784\u6210\u3002<BR>&nbsp;&nbsp;&nbsp; <STRONG>POM<\/STRONG>\uff1aPOM(pom.xml)\u662fMaven\u7684\u6838\u5fc3\u6587\u4ef6\uff0c\u5b83\u662f\u6307\u793aMaven\u5982\u4f55\u5de5\u4f5c\u7684\u5143\u6570\u636e\u6587\u4ef6\uff0c\u7c7b\u4f3c\u4e8eAnt\u4e2d\u7684build.xml\u6587\u4ef6\u3002POM\u6587\u4ef6\u4f4d\u4e8e\u6bcf\u4e2a\u5de5\u7a0b\u7684\u6839\u76ee\u5f55\u4e2d\u3002<BR>&nbsp;&nbsp;&nbsp; <STRONG>GroupId<\/STRONG>\uff1agroupId\u662f\u4e00\u4e2a\u5de5\u7a0b\u7684\u5728\u5168\u5c40\u4e2d\u552f\u4e00\u7684\u6807\u8bc6\u7b26\uff0c\u4e00\u822c\u5730\uff0c\u5b83\u5c31\u662f\u5de5\u7a0b\u540d\u3002groupId\u6709\u5229\u4e8e\u4f7f\u7528\u4e00\u4e2a\u5b8c\u5168\u7684\u5305\u540d\uff0c\u5c06\u4e00\u4e2a\u5de5\u7a0b\u4ece\u5176\u5b83\u6709\u7c7b\u4f3c\u540d\u79f0\u7684\u5de5\u7a0b\u91cc\u533a\u522b\u51fa\u6765\u3002<BR>&nbsp;&nbsp;&nbsp; <STRONG>Artifact<\/STRONG>\uff1aartifact\u662f\u5de5\u7a0b\u5c06\u8981\u4ea7\u751f\u6216\u9700\u8981\u4f7f\u7528\u7684\u6587\u4ef6\uff0c\u5b83\u53ef\u4ee5\u662fjar\u6587\u4ef6\uff0c\u6e90\u6587\u4ef6\uff0c\u4e8c\u8fdb\u5236\u6587\u4ef6\uff0cwar\u6587\u4ef6\uff0c\u751a\u81f3\u662fpom\u6587\u4ef6\u3002\u6bcf\u4e2aartifact\u90fd\u7531groupId\u548cartifactId\u7ec4\u5408\u7684\u6807\u8bc6\u7b26\u552f\u4e00\u8bc6\u522b\u3002\u9700\u8981\u88ab\u4f7f\u7528(\u4f9d\u8d56)\u7684artifact\u90fd\u8981\u653e\u5728\u4ed3\u5e93(\u89c1Repository)\u4e2d\uff0c\u5426\u5219Maven\u65e0\u6cd5\u627e\u5230(\u8bc6\u522b)\u5b83\u4eec\u3002<BR>&nbsp;&nbsp;&nbsp; <STRONG>Dependency<\/STRONG>\uff1a\u4e3a\u4e86\u80fd\u591fbuild\u6216\u8fd0\u884c\uff0c\u4e00\u4e2a\u5178\u578b\u7684Java\u5de5\u7a0b\u4f1a\u4f9d\u8d56\u5176\u5b83\u7684\u5305\u3002\u5728Maven\u4e2d\uff0c\u8fd9\u4e9b\u88ab\u4f9d\u8d56\u7684\u5305\u5c31\u88ab\u79f0\u4e3adependency\u3002dependency\u4e00\u822c\u662f\u5176\u5b83\u5de5\u7a0b\u7684artifact\u3002<BR>&nbsp;&nbsp;&nbsp; <STRONG>Plug-in<\/STRONG>\uff1aMaven\u662f\u7531\u63d2\u4ef6\u7ec4\u7ec7\u7684\uff0c\u5b83\u7684\u6bcf\u4e00\u4e2a\u529f\u80fd\u90fd\u662f\u7531\u63d2\u4ef6\u63d0\u4f9b\u7684\u3002\u63d2\u4ef6\u63d0\u4f9bgoal(\u7c7b\u4f3c\u4e8eAnt\u4e2d\u7684target)\uff0c\u5e76\u6839\u636e\u5728POM\u4e2d\u627e\u5230\u7684\u5143\u6570\u636e\u53bb\u5b8c\u6210\u5de5\u4f5c\u3002\u4e3b\u8981\u7684Maven\u63d2\u4ef6\u8981\u662f\u7531Java\u5199\u6210\u7684\uff0c\u4f46\u5b83\u4e5f\u652f\u6301\u7528Beanshell\u6216Ant\u811a\u672c\u5199\u6210\u7684\u63d2\u4ef6\u3002<BR>&nbsp;&nbsp;&nbsp; <STRONG>Repository<\/STRONG>\uff1a\u4ed3\u5e93\u7528\u4e8e\u5b58\u653eartifact\uff0c\u5b83\u53ef\u4ee5\u662f\u672c\u5730\u4ed3\u5e93\uff0c\u4e5f\u53ef\u4ee5\u662f\u8fdc\u7a0b\u4ed3\u5e93\u3002Maven\u6709\u4e00\u4e2a\u9ed8\u8ba4\u7684\u8fdc\u7a0b\u4ed3\u5e93&#8211;central\uff0c\u53ef\u4ee5\u4ece<FONT color=#0000ff>http:\/\/www.ibiblio.org\/maven2\/<\/FONT>\u4e0b\u8f7d\u5176\u4e2d\u7684artifact\u3002\u5728Windows\u5e73\u53f0\u4e0a\uff0c\u672c\u5730\u4ed3\u5e93\u7684\u9ed8\u8ba4\u5730\u5740\u662f<FONT color=#0000ff><EM>User_Home<\/EM>\\.m2\\repository<\/FONT>\u3002<BR>&nbsp;&nbsp;&nbsp; <STRONG>Snapshot<\/STRONG>\uff1a\u5de5\u7a0b\u4e2d\u53ef\u4ee5(\u4e5f\u5e94\u8be5)\u6709\u4e00\u4e2a\u7279\u6b8a\u7248\u672c\uff0c\u5b83\u7684\u7248\u672c\u53f7\u5305\u62ec<EM>SNAPSHOT<\/EM>\u5b57\u6837\u3002\u8be5\u7248\u672c\u53ef\u4ee5\u544a\u8bc9Maven\uff0c\u8be5\u5de5\u7a0b\u6b63\u5904\u4e8e\u5f00\u53d1\u9636\u6bb5\uff0c\u4f1a\u7ecf\u5e38\u66f4\u65b0(\u4f46\u8fd8\u672a\u53d1\u5e03)\u3002\u5f53\u5176\u5b83\u5de5\u7a0b\u4f7f\u7528\u6b64\u7c7b\u578b\u7248\u672c\u7684artifact\u65f6\uff0cMaven\u4f1a\u5728\u4ed3\u5e93\u4e2d\u5bfb\u627e\u8be5artifact\u7684\u6700\u65b0\u7248\u672c\uff0c\u5e76\u81ea\u52a8\u4e0b\u8f7d\u3001\u4f7f\u7528\u8be5\u6700\u65b0\u7248\u3002<BR><STRONG>2 Maven Build Life Cycle<\/STRONG><BR>&nbsp;&nbsp;&nbsp; \u8f6f\u4ef6\u9879\u76ee\u4e00\u822c\u90fd\u6709\u76f8\u4f3c\u7684\u5f00\u53d1\u8fc7\u7a0b\uff1a\u51c6\u5907\uff0c\u7f16\u8bd1\uff0c\u6d4b\u8bd5\uff0c\u6253\u5305\u548c\u90e8\u7f72\uff0cMaven\u5c06\u4e0a\u8ff0\u8fc7\u7a0b\u79f0\u4e3aBuild Life Cycle\u3002\u5728Maven\u4e2d\uff0c\u8fd9\u4e9b\u751f\u547d\u5468\u671f\u7531\u4e00\u7cfb\u5217\u7684\u77ed\u8bed\u7ec4\u6210\uff0c\u6bcf\u4e2a\u77ed\u8bed\u5bf9\u5e94\u7740\u4e00\u4e2a(\u6216\u591a\u4e2a)\u64cd\u4f5c\uff1b\u6216\u5bf9\u5e94\u7740\u4e00\u4e2a(\u6216\u591a\u4e2a)goal(\u7c7b\u4f3c\u4e8eAnt\u4e2d\u7684target)\u3002<BR>&nbsp;&nbsp;&nbsp; \u5982\u7f16\u8bd1\u6e90\u6587\u4ef6\u7684\u547d\u4ee4<FONT color=#0000ff>mvn compile<\/FONT>\u4e2d\u7684compile\u662f\u4e00\u4e2a\u751f\u547d\u5468\u671f\u77ed\u8bed\u3002\u540c\u65f6\u8be5\u547d\u4ee4\u4e5f\u53ef\u4ee5\u7b49\u4ef7\u4e8e<FONT color=#0000ff>mvn compiler:compile<\/FONT>\uff0c\u5176\u4e2d\u7684compiler\u662f\u4e00\u4e2a\u63d2\u4ef6\uff0c\u5b83\u63d0\u4f9b\u4e86compile(<STRONG>\u6b64compile\u4e0emvn compile\u4e2d\u7684compile\u610f\u4e49\u4e0d\u540c<\/STRONG>)goal\uff1bcompiler\u8fd8\u53ef\u63d0\u4f9b\u53e6\u4e00\u4e2agoal&#8211;testCompile\uff0c\u8be5goal\u7528\u4e8e\u7f16\u8bd1junit\u6d4b\u8bd5\u7c7b\u3002<BR>&nbsp;&nbsp;&nbsp; \u5728\u6267\u884c\u67d0\u4e00\u4e2a\u751f\u547d\u5468\u671f\u65f6\uff0cMaven\u4f1a\u9996\u5148\u6267\u884c\u8be5\u751f\u547d\u5468\u671f\u4e4b\u524d\u7684\u5176\u5b83\u5468\u671f\u3002\u5982\u8981\u6267\u884ccompile\uff0c\u90a3\u4e48\u5c06\u9996\u5148\u6267\u884cvalidate\uff0cgenerate-source\uff0cprocess-source\u548cgenerate-resources\uff0c\u6700\u540e\u518d\u6267\u884ccompile\u672c\u8eab\u3002<EM>\u5173\u4e8eMaven\u4e2d\u9ed8\u8ba4\u7684\u751f\u547d\u5468\u671f\u77ed\u8bed\uff0c\u8bf7\u89c1\u53c2\u8003\u8d44\u6e90[6]\u4e2d\u7684\u9644\u5f55B.3<\/EM>\u3002<BR><STRONG>3 \u6807\u51c6\u76ee\u5f55\u5e03\u5c40<\/STRONG><BR>&nbsp;&nbsp;&nbsp; Maven\u4e3a\u5de5\u7a0b\u4e2d\u7684\u6e90\u6587\u4ef6\uff0c\u8d44\u6e90\u6587\u4ef6\uff0c\u914d\u7f6e\u6587\u4ef6\uff0c\u751f\u6210\u7684\u8f93\u51fa\u548c\u6587\u6863\u90fd\u5236\u5b9a\u4e86\u4e00\u4e2a\u6807\u51c6\u7684\u76ee\u5f55\u7ed3\u6784\u3002Maven\u9f13\u52b1\u4f7f\u7528\u6807\u51c6\u76ee\u5f55\u5e03\u5c40\uff0c\u8fd9\u6837\u5c31\u4e0d\u9700\u8981\u8fdb\u884c\u989d\u5916\u7684\u914d\u7f6e\uff0c\u800c\u4e14\u6709\u52a9\u4e8e\u5404\u4e2a\u4e0d\u540c\u5de5\u7a0b\u4e4b\u95f4\u7684\u8054\u63a5\u3002\u5f53\u7136\uff0cMaven\u4e5f\u5141\u8bb8\u5b9a\u5236\u4e2a\u6027\u7684\u76ee\u5f55\u5e03\u5c40\uff0c\u8fd9\u5c31\u9700\u8981\u8fdb\u884c\u66f4\u591a\u7684\u914d\u7f6e\u3002<EM>\u5173\u4e8eMaven\u7684\u6807\u51c6\u76ee\u5f55\u5e03\u5c40\uff0c\u8bf7\u89c1\u53c2\u8003\u8d44\u6e90[6]\u4e2d\u7684\u9644\u5f55B.1<\/EM>\u3002<BR><STRONG>4 Maven\u7684\u4f18\u70b9<\/STRONG><BR>&nbsp;&nbsp;&nbsp; [1]build\u903b\u8f91\u53ef\u4ee5\u88ab\u91cd\u7528\u3002\u5728Ant\u4e2d\u53ef\u80fd\u9700\u8981\u591a\u6b21\u91cd\u590d\u5730\u5199\u76f8\u540c\u7684\u8bed\u53e5\uff0c\u4f46\u7531\u4e8ePOM\u7684\u7ee7\u627f\u6027\uff0c\u53ef\u4ee5\u590d\u7528\u5176\u5b83\u7684POM\u6587\u4ef6\u4e2d\u7684\u8bed\u53e5\u3002\u8fd9\u6837\u65e2\u53ef\u4ee5\u5199\u51fa\u6e05\u6670\u7684build\u8bed\u53e5\uff0c\u53c8\u53ef\u4ee5\u6784\u9020\u51fa\u5c42\u6b21\u5173\u7cfb\u826f\u597d\u7684build\u5de5\u7a0b\u3002<BR>&nbsp;&nbsp;&nbsp; [2]\u4e0d\u5fc5\u5173\u6ce8build\u5de5\u4f5c\u7684\u5b9e\u73b0\u7ec6\u8282\u3002\u6211\u4eec\u53ea\u9700\u8981\u4f7f\u7528\u4e00\u4e9bbuild\u751f\u547d\u5468\u671f\u77ed\u8bed\u5c31\u53ef\u4ee5\u8fbe\u5230\u6211\u4eec\u7684\u76ee\u6807\uff0c\u800c\u4e0d\u5fc5\u7ba1Maven\u662f\u5982\u4f55\u505a\u5230\u8fd9\u4e9b\u7684\u3002\u5982\uff0c\u53ea\u9700\u8981\u544a\u8bc9Maven\u8981\u5b89\u88c5(install)\uff0c\u90a3\u4e48\u5b83\u81ea\u7136\u5c31\u4f1a\u9a8c\u8bc1\uff0c\u7f16\u8bd1\uff0c\u6253\u5305\uff0c\u53ca\u5b89\u88c5\u3002<BR>&nbsp;&nbsp;&nbsp; [3]Maven\u4f1a\u81ea\u52a8\u52a0\u8f7d\u5de5\u7a0b\u4f9d\u8d56\u7684artifact\u6240\u4f9d\u8d56\u7684\u5176\u5b83artifact(Transitive Dependency)\uff0c\u800c\u4e0d\u7528\u663e\u793a\u7684\u5c06\u8fd9\u4e9bartifact\u5168\u90e8\u5199\u5230dependency\u4e2d\u3002<BR>&nbsp;&nbsp;&nbsp; [4]\u5982\u679c\u5b8c\u5168\u4f7f\u7528Maven\u7684\u6807\u51c6\u76ee\u5f55\u5e03\u5c40\uff0c\u90a3\u4e48\u53ef\u4ee5\u6781\u5927\u5730\u51cf\u5c11\u914d\u7f6e\u7ec6\u8282\u3002<BR><STRONG>5 \u5b9e\u4f8b<\/STRONG><BR><STRONG>5.1 \u6784\u60f3<\/STRONG><BR>&nbsp;&nbsp;&nbsp; \u7531\u4e8e\u53ea\u662f\u9610\u8ff0Maven\u7684\u57fa\u672c\u4f7f\u7528\u65b9\u6cd5\uff0c\u6240\u4ee5\u672c\u6587\u5c06\u8981\u8bbe\u8ba1\u7684\u5b9e\u4f8b\uff0c\u53ea\u662f\u4e00\u4e2a\u7b80\u5355\u7684Maven demo\u3002\u8be5\u5b9e\u4f8b\u5305\u542b\u4e24\u4e2a\u5de5\u7a0b\uff1a\u666e\u901a\u5e94\u7528\u7a0b\u5e8f\u5de5\u7a0b(app)\u548cWeb\u5e94\u7528\u5de5\u7a0b(webapp)\u3002app\u5de5\u7a0b\u63d0\u4f9b\u4e00\u4e2a\u7b80\u5355\u7684Java\u7c7b\uff1bwebapp\u5de5\u7a0b\u53ea\u5305\u542b\u4e00\u4e2aServlet\uff0c\u5e76\u5c06\u4f7f\u7528app\u4e2d\u7684Java\u7c7b\u3002<BR>&nbsp;&nbsp;&nbsp; \u8be5Demo\u7684\u76ee\u6807\u662f\u80fd\u591f\u6b63\u786e\u5730\u5c06webapp\u5236\u6210war\u5305\uff0c\u4ee5\u4f9b\u90e8\u7f72\u65f6\u4f7f\u7528\u3002\u8981\u80fd\u591f\u6b63\u786e\u5236\u4f5cwar\uff0c\u81ea\u7136\u9996\u5148\u5c31\u5fc5\u987b\u8981\u80fd\u591f\u6b63\u786e\u7684\u7f16\u8bd1\u6e90\u4ee3\u7801\uff0c\u4e14\u8981\u5c06App\u6a21\u5757\u5236\u6210jar\u5305\u3002\u672c\u6587\u521b\u5efa\u7684\u5de5\u7a0b\u6240\u5728\u7684\u76ee\u5f55\u662f<FONT color=#0000ff>D:\\maven\\demo<\/FONT>\u3002<BR><STRONG>5.2 App\u5de5\u7a0b<\/STRONG><BR>&nbsp;&nbsp;&nbsp; \u53ef\u4ee5\u4f7f\u7528Maven\u7684archetype\u63d2\u4ef6\u6765\u521b\u5efa\u65b0\u5de5\u7a0b\uff0c\u547d\u4ee4\u5982\u4e0b\uff1a<BR>&nbsp;&nbsp;&nbsp; <FONT color=#0000ff>D:\\maven\\demo&gt;mvn archetype:create -DgroupId=ce.demo.mvn -DartifactId=app<\/FONT><BR>\u8be5\u5de5\u7a0b\u7684groupId\u662fce.demo.mvn\uff0c\u90a3\u4e48\u8be5\u5de5\u7a0b\u7684\u6e90\u6587\u4ef6\u5c06\u653e\u5728Java\u5305ce.demo.mvn\u4e2d\u3002artifactId\u662fapp\uff0c\u90a3\u4e48\u8be5\u5de5\u7a0b\u6839\u76ee\u5f55\u7684\u540d\u79f0\u5c06\u4e3aapp\u3002<BR>&nbsp;&nbsp;&nbsp; \u5f53\u7b2c\u4e00\u6b21\u6267\u884c\u8be5\u547d\u4ee4\u65f6\uff0cMaven\u4f1a\u4ececentral\u4ed3\u5e93\u4e2d\u4e0b\u8f7d\u4e00\u4e9b\u6587\u4ef6\u3002\u8fd9\u4e9b\u6587\u4ef6\u5305\u542b\u63d2\u4ef6archetype\uff0c\u4ee5\u53ca\u5b83\u6240\u4f9d\u8d56\u7684\u5176\u5b83\u5305\u3002\u8be5\u547d\u4ee4\u6267\u884c\u5b8c\u6bd5\u540e\uff0c\u5728\u76ee\u5f55D:\\maven\\demo\u4e0b\u4f1a\u51fa\u73b0\u5982\u4e0b\u76ee\u5f55\u5e03\u5c40\uff1a<BR><br \/>\n<DIV style=\"BORDER-RIGHT: rgb(204,204,204) 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(204,204,204) 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: rgb(204,204,204) 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: rgb(204,204,204) 1px solid; BACKGROUND-COLOR: rgb(238,238,238)\"><!--\n\nCode highlighting produced by Actipro CodeHighlighter (freeware)<br \/><a href=\"http:\/\/www.CodeHighlighter.com\/\" target=\"_blank\">http:\/\/www.CodeHighlighter.com\/<\/a>\n\n--><SPAN style=\"COLOR: rgb(0,0,0)\"><FONT size=2>app<BR>|&#8211;&nbsp;pom.xml<BR>`&#8211;&nbsp;src<BR>&nbsp;&nbsp;&nbsp;&nbsp;|&#8211;&nbsp;main<BR>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;`&#8211;&nbsp;java<BR>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`&#8211;&nbsp;ce<BR>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`&#8211;&nbsp;demo<BR>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`&#8211;&nbsp;mvn<BR>&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`&#8211;&nbsp;App.java<BR>&nbsp;&nbsp;&nbsp;&nbsp;`&#8211;&nbsp;test<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`&#8211;&nbsp;java<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`&#8211;&nbsp;ce<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`&#8211;&nbsp;demo<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`&#8211;&nbsp;mvn<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`&#8211;&nbsp;AppTest.java<\/FONT><\/SPAN><\/DIV>\u56e0\u672c\u6587\u6682\u65f6\u4e0d\u6d89\u53caJUnit\u6d4b\u8bd5\uff0c\u6545\u8bf7\u5c06\u76ee\u5f55<FONT color=#0000ff>app\\src\\test<\/FONT>\u76ee\u5f55\u5220\u9664(\u4e0d\u5220\u9664\u4e5f\u6ca1\u5173\u7cfb ^_^)\u3002\u7136\u540e\u518d\u4fee\u6539App.java\u6587\u4ef6\uff0c\u5176\u5b8c\u5168\u5185\u5bb9\u5982\u4e0b\uff1a<BR><FONT color=#008000><br \/>\n<DIV style=\"BORDER-RIGHT: rgb(204,204,204) 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(204,204,204) 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: rgb(204,204,204) 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: rgb(204,204,204) 1px solid; BACKGROUND-COLOR: rgb(238,238,238)\"><FONT size=2><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/None.gif\" align=top _counted=\"undefined\"><SPAN style=\"COLOR: rgb(0,0,255)\">package<\/SPAN><\/FONT><FONT size=2><SPAN style=\"COLOR: rgb(0,0,0)\">&nbsp;ce.demo.mvn;<BR><IMG id=Codehighlighter1_38_105_Open_Image onclick=\"this.style.display='none'; Codehighlighter1_38_105_Open_Text.style.display='none'; Codehighlighter1_38_105_Closed_Image.style.display='inline'; Codehighlighter1_38_105_Closed_Text.style.display='inline';\" alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/ExpandedBlockStart.gif\" align=top _counted=\"undefined\"><IMG id=Codehighlighter1_38_105_Closed_Image style=\"DISPLAY: none\" onclick=\"this.style.display='none'; Codehighlighter1_38_105_Closed_Text.style.display='none'; Codehighlighter1_38_105_Open_Image.style.display='inline'; Codehighlighter1_38_105_Open_Text.style.display='inline';\" alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/ContractedBlock.gif\" align=top _counted=\"undefined\"><\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">public<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">&nbsp;<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">class<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">&nbsp;App&nbsp;<\/SPAN><SPAN id=Codehighlighter1_38_105_Closed_Text style=\"BORDER-RIGHT: rgb(128,128,128) 1px solid; BORDER-TOP: rgb(128,128,128) 1px solid; DISPLAY: none; BORDER-LEFT: rgb(128,128,128) 1px solid; BORDER-BOTTOM: rgb(128,128,128) 1px solid; BACKGROUND-COLOR: rgb(255,255,255)\"><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/dot.gif\" _counted=\"undefined\"><\/SPAN><\/FONT><SPAN id=Codehighlighter1_38_105_Open_Text><FONT size=2><SPAN style=\"COLOR: rgb(0,0,0)\">{<BR><IMG id=Codehighlighter1_77_103_Open_Image onclick=\"this.style.display='none'; Codehighlighter1_77_103_Open_Text.style.display='none'; Codehighlighter1_77_103_Closed_Image.style.display='inline'; Codehighlighter1_77_103_Closed_Text.style.display='inline';\" alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/ExpandedSubBlockStart.gif\" align=top _counted=\"undefined\"><IMG id=Codehighlighter1_77_103_Closed_Image style=\"DISPLAY: none\" onclick=\"this.style.display='none'; Codehighlighter1_77_103_Closed_Text.style.display='none'; Codehighlighter1_77_103_Open_Image.style.display='inline'; Codehighlighter1_77_103_Open_Text.style.display='inline';\" alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/ContractedSubBlock.gif\" align=top _counted=\"undefined\">&nbsp;&nbsp;&nbsp;&nbsp;<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">public<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">&nbsp;String&nbsp;getStr(String&nbsp;str)&nbsp;<\/SPAN><SPAN id=Codehighlighter1_77_103_Closed_Text style=\"BORDER-RIGHT: rgb(128,128,128) 1px solid; BORDER-TOP: rgb(128,128,128) 1px solid; DISPLAY: none; BORDER-LEFT: rgb(128,128,128) 1px solid; BORDER-BOTTOM: rgb(128,128,128) 1px solid; BACKGROUND-COLOR: rgb(255,255,255)\"><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/dot.gif\" _counted=\"undefined\"><\/SPAN><\/FONT><SPAN id=Codehighlighter1_77_103_Open_Text><FONT size=2><SPAN style=\"COLOR: rgb(0,0,0)\">{<BR><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/InBlock.gif\" align=top _counted=\"undefined\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">return<\/SPAN><\/FONT><SPAN style=\"COLOR: rgb(0,0,0)\"><FONT size=2>&nbsp;str;<BR><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/ExpandedSubBlockEnd.gif\" align=top _counted=\"undefined\">&nbsp;&nbsp;&nbsp;&nbsp;}<\/FONT><\/SPAN><\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\"><BR><FONT size=2><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/ExpandedBlockEnd.gif\" align=top _counted=\"undefined\">}<\/FONT><\/SPAN><\/SPAN><\/DIV><\/FONT>\u5176\u5b9e\uff0c\u5982\u679c\u6211\u4eec\u80fd\u591f\u6e05\u695a\u5730\u77e5\u9053Maven\u7684\u6807\u51c6\u76ee\u5f55\u5e03\u5c40\uff0c\u5c31\u53ef\u4ee5\u4e0d\u4f7f\u7528archetype\u63d2\u4ef6\u6765\u521b\u5efa\u5de5\u7a0b\u539f\u578b\uff1b\u5982\u679c\u6211\u4eec\u8981\u5b9a\u5236\u4e2a\u6027\u7684\u76ee\u5f55\u5e03\u5c40\uff0c\u90a3\u4e48\u5c31\u66f4\u6ca1\u6709\u5fc5\u8981\u4f7f\u7528archetype\u63d2\u4ef6\u4e86\u3002<BR><STRONG>5.3 WebApp\u5de5\u7a0b<\/STRONG><BR>&nbsp;&nbsp;&nbsp; \u6211\u4eec\u4ecd\u7136\u5982\u521b\u5efaapp\u5de5\u7a0b\u4e00\u6837\u4f7f\u7528archetype\u63d2\u4ef6\u6765\u521b\u5efawebapp\u5de5\u7a0b\uff0c\u547d\u4ee4\u5982\u4e0b\uff1a<BR>&nbsp;&nbsp;&nbsp; <FONT color=#0000ff>D:\\maven\\demo&gt;mvn archetype:create -DgroupId=ce.demo.mvn -DartifactId=webapp -DarchetypeArtifactId=maven-archetype-webapp<\/FONT><BR>&nbsp;&nbsp;&nbsp; \u7b2c\u4e00\u6b21\u8fd0\u884c\u6b64\u547d\u4ee4\u65f6\uff0c\u4e5f\u4f1a\u4ececentral\u4ed3\u5e93\u4e2d\u4e0b\u8f7d\u4e00\u4e9b\u4e0eWeb\u5e94\u7528\u76f8\u5173\u7684artifact(\u5982javax.servlet)\u3002\u6b64\u547d\u4ee4\u4e0e\u521b\u5efaapp\u7684\u547d\u4ee4\u7684\u4e0d\u540c\u4e4b\u5904\u662f\uff0c\u591a\u8bbe\u7f6e\u4e86\u4e00\u4e2a\u5c5e\u6027archetypeArtifacttId\uff0c\u8be5\u5c5e\u6027\u7684\u503c\u4e3amaven-archetype-webapp\u3002\u5373\u544a\u8bc9Maven\uff0c\u5c06\u8981\u521b\u5efa\u7684\u5de5\u7a0b\u662f\u4e00\u4e2aWeb\u5e94\u7528\u5de5\u7a0b\u3002\u521b\u5efaapp\u5de5\u7a0b\u65f6\u6ca1\u6709\u4f7f\u7528\u8be5\u5c5e\u6027\u503c\uff0c\u662f\u7531\u4e8earchetype\u9ed8\u8ba4\u521b\u5efa\u7684\u662f\u5e94\u7528\u7a0b\u5e8f\u5de5\u7a0b\u3002\u540c\u6837\u7684\uff0c\u6267\u884c\u5b8c\u8be5\u547d\u4ee4\u4e4b\u540e\uff0c\u4f1a\u51fa\u73b0\u5982\u4e0b\u6807\u51c6\u76ee\u5f55\u5e03\u5c40\uff1a<BR><br \/>\n<DIV style=\"BORDER-RIGHT: rgb(204,204,204) 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(204,204,204) 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: rgb(204,204,204) 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: rgb(204,204,204) 1px solid; BACKGROUND-COLOR: rgb(238,238,238)\"><!--\n\nCode highlighting produced by Actipro CodeHighlighter (freeware)<br \/><a href=\"http:\/\/www.CodeHighlighter.com\/\" target=\"_blank\">http:\/\/www.CodeHighlighter.com\/<\/a>\n\n--><FONT size=2><SPAN style=\"COLOR: rgb(0,0,0)\">webapp<BR>|&#8211;&nbsp;pom.xml<BR>`&#8211;&nbsp;src<BR>&nbsp;&nbsp;&nbsp;&nbsp;`&#8211;&nbsp;main<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`&#8211;&nbsp;webapp<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">|<\/SPAN><\/FONT><SPAN style=\"COLOR: rgb(0,0,0)\"><FONT size=2>&#8212;&nbsp;index.jsp<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; |&#8211;&nbsp;WEB-INF<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp; `&#8211;&nbsp;web.xml<\/FONT><\/SPAN><\/DIV>&nbsp;&nbsp;&nbsp; \u6839\u636e5.1\u8282\u7684\u6784\u60f3\uff0cwebapp\u5de5\u7a0b\u5c06\u53ea\u5305\u542b\u4e00\u4e2aServlet\uff0c\u6240\u4ee5\u6211\u4eec\u4e0d\u9700\u8981index.jsp\u6587\u4ef6\uff0c\u8bf7\u5c06\u5176\u5220\u9664\u3002\u6b64\u65f6\u5927\u5bb6\u53ef\u4ee5\u53d1\u73b0\uff0c\u76ee\u524d\u7684\u76ee\u5f55\u5e03\u5c40\u4e2d\u5e76\u6ca1\u6709\u653eServlet\uff0c\u5373Java\u6e90\u6587\u4ef6\u7684\u5730\u65b9\u3002\u6839\u636e\u53c2\u8003\u8d44\u6e90[6]\u4e2d\u7684\u9644\u5f55B.1\uff0c\u4ee5\u53caapp\u5de5\u7a0b\u4e2dJava\u6e90\u6587\u4ef6\u7684\u5e03\u5c40\uff0c\u53ef\u4ee5\u77e5\u9053Servlet\uff08\u5b83\u4ecd\u7136\u662f\u4e00\u4e2aJava\u7c7b\u6587\u4ef6\uff09\u4ecd\u7136\u662f\u653e\u5728<FONT color=#0000ff>webapp\\src\\main\\java<\/FONT>\u76ee\u5f55\u4e2d\uff0c\u8bf7\u65b0\u5efa\u8be5\u76ee\u5f55\u3002\u6b64\u5904\u7684Servlet\u662f\u4e00\u4e2a\u7b80\u5355HelloServlet\uff0c\u5176\u5b8c\u6574\u4ee3\u7801\u5982\u4e0b\uff1a<BR><br \/>\n<DIV style=\"BORDER-RIGHT: rgb(204,204,204) 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(204,204,204) 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: rgb(204,204,204) 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: rgb(204,204,204) 1px solid; BACKGROUND-COLOR: rgb(238,238,238)\"><FONT size=2><FONT color=#008000><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/None.gif\" align=top _counted=\"undefined\"><\/FONT><SPAN style=\"COLOR: rgb(0,0,255)\">package<\/SPAN><\/FONT><FONT size=2><SPAN style=\"COLOR: rgb(0,0,0)\">&nbsp;hello;<BR><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/None.gif\" align=top _counted=\"undefined\"><BR><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/None.gif\" align=top _counted=\"undefined\"><\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">import<\/SPAN><\/FONT><FONT size=2><SPAN style=\"COLOR: rgb(0,0,0)\">&nbsp;java.io.IOException;<BR><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/None.gif\" align=top _counted=\"undefined\"><\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">import<\/SPAN><\/FONT><FONT size=2><SPAN style=\"COLOR: rgb(0,0,0)\">&nbsp;java.io.PrintWriter;<BR><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/None.gif\" align=top _counted=\"undefined\"><\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">import<\/SPAN><\/FONT><FONT size=2><SPAN style=\"COLOR: rgb(0,0,0)\">&nbsp;javax.servlet.ServletException;<BR><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/None.gif\" align=top _counted=\"undefined\"><\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">import<\/SPAN><\/FONT><FONT size=2><SPAN style=\"COLOR: rgb(0,0,0)\">&nbsp;javax.servlet.http.HttpServlet;<BR><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/None.gif\" align=top _counted=\"undefined\"><\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">import<\/SPAN><\/FONT><FONT size=2><SPAN style=\"COLOR: rgb(0,0,0)\">&nbsp;javax.servlet.http.HttpServletRequest;<BR><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/None.gif\" align=top _counted=\"undefined\"><\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">import<\/SPAN><\/FONT><FONT size=2><SPAN style=\"COLOR: rgb(0,0,0)\">&nbsp;javax.servlet.http.HttpServletResponse;<BR><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/None.gif\" align=top _counted=\"undefined\"><BR><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/None.gif\" align=top _counted=\"undefined\"><\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">import<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">&nbsp;ce.demo.mvn.App;&nbsp;&nbsp;<\/SPAN><SPAN style=\"COLOR: rgb(0,128,0)\">\/\/<\/SPAN><SPAN style=\"COLOR: rgb(0,128,0)\">&nbsp;\u5f15\u7528app\u5de5\u7a0b\u4e2d\u7684App\u7c7b<\/SPAN><\/FONT><SPAN style=\"COLOR: rgb(0,128,0)\"><BR><FONT size=2><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/None.gif\" align=top _counted=\"undefined\"><\/FONT><\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\"><BR><FONT size=2><IMG id=Codehighlighter1_333_776_Open_Image onclick=\"this.style.display='none'; Codehighlighter1_333_776_Open_Text.style.display='none'; Codehighlighter1_333_776_Closed_Image.style.display='inline'; Codehighlighter1_333_776_Closed_Text.style.display='inline';\" alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/ExpandedBlockStart.gif\" align=top _counted=\"undefined\"><IMG id=Codehighlighter1_333_776_Closed_Image style=\"DISPLAY: none\" onclick=\"this.style.display='none'; Codehighlighter1_333_776_Closed_Text.style.display='none'; Codehighlighter1_333_776_Open_Image.style.display='inline'; Codehighlighter1_333_776_Open_Text.style.display='inline';\" alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/ContractedBlock.gif\" align=top _counted=\"undefined\"><\/FONT><\/SPAN><FONT size=2><SPAN style=\"COLOR: rgb(0,0,255)\">public<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">&nbsp;<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">class<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">&nbsp;HelloServlet&nbsp;<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">extends<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">&nbsp;HttpServlet&nbsp;<\/SPAN><SPAN id=Codehighlighter1_333_776_Closed_Text style=\"BORDER-RIGHT: rgb(128,128,128) 1px solid; BORDER-TOP: rgb(128,128,128) 1px solid; DISPLAY: none; BORDER-LEFT: rgb(128,128,128) 1px solid; BORDER-BOTTOM: rgb(128,128,128) 1px solid; BACKGROUND-COLOR: rgb(255,255,255)\"><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/dot.gif\" _counted=\"undefined\"><\/SPAN><\/FONT><SPAN id=Codehighlighter1_333_776_Open_Text><FONT size=2><SPAN style=\"COLOR: rgb(0,0,0)\">{<BR><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/InBlock.gif\" align=top _counted=\"undefined\">&nbsp;&nbsp;&nbsp;&nbsp;<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">private<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">&nbsp;<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">static<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">&nbsp;<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">final<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">&nbsp;<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">long<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">&nbsp;serialVersionUID&nbsp;<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">=<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">&nbsp;<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">&#8211;<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">3696470690560528247L<\/SPAN><\/FONT><FONT size=2><SPAN style=\"COLOR: rgb(0,0,0)\">;<BR><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/InBlock.gif\" align=top _counted=\"undefined\">&nbsp;&nbsp;&nbsp;&nbsp;<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">public<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">&nbsp;<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">void<\/SPAN><\/FONT><FONT size=2><SPAN style=\"COLOR: rgb(0,0,0)\">&nbsp;doGet(HttpServletRequest&nbsp;request,&nbsp;HttpServletResponse&nbsp;response)<BR><IMG id=Codehighlighter1_536_774_Open_Image onclick=\"this.style.display='none'; Codehighlighter1_536_774_Open_Text.style.display='none'; Codehighlighter1_536_774_Closed_Image.style.display='inline'; Codehighlighter1_536_774_Closed_Text.style.display='inline';\" alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/ExpandedSubBlockStart.gif\" align=top _counted=\"undefined\"><IMG id=Codehighlighter1_536_774_Closed_Image style=\"DISPLAY: none\" onclick=\"this.style.display='none'; Codehighlighter1_536_774_Closed_Text.style.display='none'; Codehighlighter1_536_774_Open_Image.style.display='inline'; Codehighlighter1_536_774_Open_Text.style.display='inline';\" alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/ContractedSubBlock.gif\" align=top _counted=\"undefined\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">throws<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">&nbsp;ServletException,&nbsp;IOException&nbsp;<\/SPAN><SPAN id=Codehighlighter1_536_774_Closed_Text style=\"BORDER-RIGHT: rgb(128,128,128) 1px solid; BORDER-TOP: rgb(128,128,128) 1px solid; DISPLAY: none; BORDER-LEFT: rgb(128,128,128) 1px solid; BORDER-BOTTOM: rgb(128,128,128) 1px solid; BACKGROUND-COLOR: rgb(255,255,255)\"><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/dot.gif\" _counted=\"undefined\"><\/SPAN><\/FONT><SPAN id=Codehighlighter1_536_774_Open_Text><FONT size=2><SPAN style=\"COLOR: rgb(0,0,0)\">{<BR><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/InBlock.gif\" align=top _counted=\"undefined\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;App&nbsp;app&nbsp;<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">=<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">&nbsp;<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">new<\/SPAN><\/FONT><FONT size=2><SPAN style=\"COLOR: rgb(0,0,0)\">&nbsp;App();<BR><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/InBlock.gif\" align=top _counted=\"undefined\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;String&nbsp;str&nbsp;<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">=<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">&nbsp;app.getStr(<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">&#8220;<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">CE&nbsp;Maven&nbsp;Demo<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">&#8220;<\/SPAN><\/FONT><FONT size=2><SPAN style=\"COLOR: rgb(0,0,0)\">);<BR><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/InBlock.gif\" align=top _counted=\"undefined\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;PrintWriter&nbsp;out&nbsp;<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">=<\/SPAN><\/FONT><FONT size=2><SPAN style=\"COLOR: rgb(0,0,0)\">&nbsp;response.getWriter();<BR><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/InBlock.gif\" align=top _counted=\"undefined\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;out.print(<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">&#8220;<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">&lt;html&gt;&lt;body&gt;<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">&#8220;<\/SPAN><\/FONT><FONT size=2><SPAN style=\"COLOR: rgb(0,0,0)\">);<BR><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/InBlock.gif\" align=top _counted=\"undefined\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;out.print(<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">&#8220;<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">&lt;h1&gt;<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">&#8220;<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">&nbsp;<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">+<\/SPAN><\/FONT><FONT size=2><SPAN style=\"COLOR: rgb(0,0,0)\">&nbsp;str);<BR><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/InBlock.gif\" align=top _counted=\"undefined\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;out.print(<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">&#8220;<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">&lt;\/body&gt;&lt;\/html&gt;<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">&#8220;<\/SPAN><\/FONT><SPAN style=\"COLOR: rgb(0,0,0)\"><FONT size=2>);<BR><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/ExpandedSubBlockEnd.gif\" align=top _counted=\"undefined\">&nbsp;&nbsp;&nbsp;&nbsp;}<\/FONT><\/SPAN><\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\"><BR><FONT size=2><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/ExpandedBlockEnd.gif\" align=top _counted=\"undefined\">}<\/FONT><\/SPAN><\/SPAN><\/DIV><STRONG>5.4 POM\u6587\u4ef6<\/STRONG><BR>&nbsp;&nbsp;&nbsp; \u5927\u5bb6\u53ef\u4ee5\u53d1\u73b0\uff0c\u5728\u524d\u9762\u65b0\u5efa\u5de5\u7a0b\u65f6\uff0c\u6211\u4eec\u5e76\u6ca1\u6709\u63d0\u5230\u5404\u4e2a\u5de5\u7a0b\u4e2d\u7684pom.xml\u6587\u4ef6\u3002\u73b0\u5728\u5c06\u8981\u8ba8\u8bba\u8fd9\u4e2a\u95ee\u9898\u3002\u6211\u4eec\u5148\u770b\u770bapp\u5de5\u7a0b\u4e2d\u7684POM\u6587\u4ef6\uff0c\u5176\u5b8c\u6574\u5185\u5bb9\u5982\u4e0b\uff1a<BR><br \/>\n<DIV style=\"BORDER-RIGHT: rgb(204,204,204) 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(204,204,204) 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: rgb(204,204,204) 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: rgb(204,204,204) 1px solid; BACKGROUND-COLOR: rgb(238,238,238)\"><FONT size=2><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/None.gif\" align=top _counted=\"undefined\"><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">project<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><\/FONT><SPAN style=\"COLOR: rgb(0,0,0)\"><BR><FONT size=2><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/None.gif\" align=top _counted=\"undefined\">&nbsp;&nbsp;<\/FONT><\/SPAN><FONT size=2><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">modelVersion<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">4.0.0<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;\/<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">modelVersion<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><\/FONT><SPAN style=\"COLOR: rgb(0,0,0)\"><BR><FONT size=2><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/None.gif\" align=top _counted=\"undefined\">&nbsp;&nbsp;<\/FONT><\/SPAN><FONT size=2><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">groupId<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">ce.demo.mvn<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;\/<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">groupId<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><\/FONT><SPAN style=\"COLOR: rgb(0,0,0)\"><BR><FONT size=2><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/None.gif\" align=top _counted=\"undefined\">&nbsp;&nbsp;<\/FONT><\/SPAN><FONT size=2><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">artifactId<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">app<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;\/<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">artifactId<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><\/FONT><SPAN style=\"COLOR: rgb(0,0,0)\"><BR><FONT size=2><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/None.gif\" align=top _counted=\"undefined\">&nbsp;&nbsp;<\/FONT><\/SPAN><FONT size=2><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">packaging<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">jar<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;\/<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">packaging<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><\/FONT><SPAN style=\"COLOR: rgb(0,0,0)\"><BR><FONT size=2><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/None.gif\" align=top _counted=\"undefined\">&nbsp;&nbsp;<\/FONT><\/SPAN><FONT size=2><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">version<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">1.0<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;\/<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">version<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><\/FONT><SPAN style=\"COLOR: rgb(0,0,0)\"><BR><FONT size=2><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/None.gif\" align=top _counted=\"undefined\">&nbsp;&nbsp;<\/FONT><\/SPAN><FONT size=2><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">name<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">CE&nbsp;Maven&nbsp;Demo&nbsp;&#8212;&nbsp;App<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;\/<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">name<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><\/FONT><SPAN style=\"COLOR: rgb(0,0,0)\"><BR><FONT size=2><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/None.gif\" align=top _counted=\"undefined\"><\/FONT><\/SPAN><FONT size=2><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;\/<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">project<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><\/FONT><\/DIV>&nbsp;&nbsp;&nbsp; \u5927\u5bb6\u53ef\u4ee5\u53d1\u73b0\u6b64\u6211\u5e16\u51fa\u6765\u7684\u5185\u5bb9\u4e0e\u5b9e\u9645\u7531archetype\u63d2\u4ef6\u751f\u6210\u7684POM\u6587\u4ef6\u7684\u5185\u5bb9\u6709\u4e9b\u4e0d\u540c\uff0c\u4f46\u57fa\u672c\u4e0a\u662f\u4e00\u81f4\u7684\u3002\u53ea\u662f\u4e3a\u4e86\u4f7f\u6587\u4ef6\u4e2d\u7684\u8bed\u53e5\u66f4\u6e05\u6670\uff0c\u6b64\u5904\u5220\u9664\u4e86\u4e00\u4e9b\u5197\u4f59\u7684\u5185\u5bb9\uff0c\u5e76\u4fee\u6539\u4e86\u8be5\u5de5\u7a0b\u7684version\u548cname\u7684\u503c\uff0c\u4ee5\u4e0e\u6b64\u4f8b\u5b50\u7684\u80cc\u666f\u6765\u7b26\u5408\u3002\u5728\u76ee\u524d\u60c5\u51b5\u4e0bmodelVersion\u503c\u5c06\u88ab\u56fa\u5b9a\u4e3a4.0.0\uff0c\u8fd9\u4e5f\u662fMaven2\u552f\u4e00\u80fd\u591f\u8bc6\u522b\u7684model\u7248\u672c\u3002groupId\uff0cartifactId\u7684\u503c\u4e0e\u521b\u5efa\u5de5\u7a0b\u65f6\u4f7f\u7528\u7684\u547d\u4ee4\u4e2d\u7684\u76f8\u5173\u5c5e\u6027\u503c\u662f\u4e00\u81f4\u7684\u3002packaging\u7684\u503c\u7531\u5de5\u7a0b\u7684\u7c7b\u578b\u51b3\u5b9a\uff0c\u5982\u5e94\u7528\u7a0b\u5e8f\u5de5\u7a0b\u7684packaging\u503c\u4e3ajar\uff0cWeb\u5e94\u7528\u5de5\u7a0b\u7684packaging\u503c\u4e3awar\u3002\u4e0a\u8ff0\u60c5\u51b5\u4e5f\u53ef\u4ee5\u4ecewebapp\u7684POM\u6587\u4ef6\u4e2d\u770b\u51fa\uff0c\u4e0b\u9762\u5c06\u770b\u770b\u8fd9\u4e2apom\u7684\u5b8c\u6574\u5185\u5bb9\u3002<BR><br \/>\n<DIV style=\"BORDER-RIGHT: rgb(204,204,204) 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(204,204,204) 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: rgb(204,204,204) 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: rgb(204,204,204) 1px solid; BACKGROUND-COLOR: rgb(238,238,238)\"><FONT size=2><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/None.gif\" align=top _counted=\"undefined\"><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">project<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><\/FONT><SPAN style=\"COLOR: rgb(0,0,0)\"><BR><FONT size=2><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/None.gif\" align=top _counted=\"undefined\">&nbsp;&nbsp;<\/FONT><\/SPAN><FONT size=2><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">modelVersion<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">4.0.0<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;\/<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">modelVersion<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><\/FONT><SPAN style=\"COLOR: rgb(0,0,0)\"><BR><FONT size=2><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/None.gif\" align=top _counted=\"undefined\">&nbsp;&nbsp;<\/FONT><\/SPAN><FONT size=2><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">groupId<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">ce.demo.mvn<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;\/<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">groupId<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><\/FONT><SPAN style=\"COLOR: rgb(0,0,0)\"><BR><FONT size=2><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/None.gif\" align=top _counted=\"undefined\">&nbsp;&nbsp;<\/FONT><\/SPAN><FONT size=2><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">artifactId<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">webapp<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;\/<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">artifactId<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><\/FONT><SPAN style=\"COLOR: rgb(0,0,0)\"><BR><FONT size=2><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/None.gif\" align=top _counted=\"undefined\">&nbsp;&nbsp;<\/FONT><\/SPAN><FONT size=2><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">packaging<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">war<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;\/<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">packaging<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><\/FONT><SPAN style=\"COLOR: rgb(0,0,0)\"><BR><FONT size=2><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/None.gif\" align=top _counted=\"undefined\">&nbsp;&nbsp;<\/FONT><\/SPAN><FONT size=2><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">version<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">1.0<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;\/<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">version<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><\/FONT><SPAN style=\"COLOR: rgb(0,0,0)\"><BR><FONT size=2><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/None.gif\" align=top _counted=\"undefined\">&nbsp;&nbsp;<\/FONT><\/SPAN><FONT size=2><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">name<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">CE&nbsp;Maven&nbsp;Demo&nbsp;&#8212;&nbsp;WebApp<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;\/<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">name<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><\/FONT><SPAN style=\"COLOR: rgb(0,0,0)\"><BR><FONT size=2><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/None.gif\" align=top _counted=\"undefined\">&nbsp;&nbsp;<BR><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/None.gif\" align=top _counted=\"undefined\">&nbsp;&nbsp;<\/FONT><\/SPAN><FONT size=2><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">dependencies<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><\/FONT><SPAN style=\"COLOR: rgb(0,0,0)\"><BR><FONT size=2><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/None.gif\" align=top _counted=\"undefined\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><\/SPAN><FONT size=2><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">dependency<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><\/FONT><SPAN style=\"COLOR: rgb(0,0,0)\"><BR><FONT size=2><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/None.gif\" align=top _counted=\"undefined\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><\/SPAN><FONT size=2><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">groupId<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">ce.demo.mvn<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;\/<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">groupId<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><\/FONT><SPAN style=\"COLOR: rgb(0,0,0)\"><BR><FONT size=2><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/None.gif\" align=top _counted=\"undefined\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><\/SPAN><FONT size=2><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">artifactId<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">app<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;\/<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">artifactId<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><\/FONT><SPAN style=\"COLOR: rgb(0,0,0)\"><BR><FONT size=2><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/None.gif\" align=top _counted=\"undefined\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><\/SPAN><FONT size=2><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">version<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">1.0<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;\/<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">version<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><\/FONT><SPAN style=\"COLOR: rgb(0,0,0)\"><BR><FONT size=2><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/None.gif\" align=top _counted=\"undefined\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><\/SPAN><FONT size=2><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;\/<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">dependency<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><\/FONT><SPAN style=\"COLOR: rgb(0,0,0)\"><BR><FONT size=2><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/None.gif\" align=top _counted=\"undefined\">&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><\/SPAN><FONT size=2><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">dependency<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><\/FONT><SPAN style=\"COLOR: rgb(0,0,0)\"><BR><FONT size=2><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/None.gif\" align=top _counted=\"undefined\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><\/SPAN><FONT size=2><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">groupId<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">javax.servlet<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;\/<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">groupId<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><\/FONT><SPAN style=\"COLOR: rgb(0,0,0)\"><BR><FONT size=2><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/None.gif\" align=top _counted=\"undefined\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><\/SPAN><FONT size=2><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">artifactId<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">servlet-api<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;\/<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">artifactId<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><\/FONT><SPAN style=\"COLOR: rgb(0,0,0)\"><BR><FONT size=2><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/None.gif\" align=top _counted=\"undefined\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><\/SPAN><FONT size=2><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">version<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">2.4<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;\/<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">version<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><\/FONT><SPAN style=\"COLOR: rgb(0,0,0)\"><BR><FONT size=2><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/None.gif\" align=top _counted=\"undefined\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><\/SPAN><FONT size=2><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">scope<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">provided<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;\/<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">scope<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><\/FONT><SPAN style=\"COLOR: rgb(0,0,0)\"><BR><FONT size=2><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/None.gif\" align=top _counted=\"undefined\">&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><\/SPAN><FONT size=2><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;\/<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">dependency<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><\/FONT><FONT size=2><SPAN style=\"COLOR: rgb(0,0,0)\">&nbsp;<BR><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/None.gif\" align=top _counted=\"undefined\">&nbsp;&nbsp;<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;\/<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">dependencies<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><\/FONT><SPAN style=\"COLOR: rgb(0,0,0)\"><BR><FONT size=2><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/None.gif\" align=top _counted=\"undefined\"><\/FONT><\/SPAN><FONT size=2><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;\/<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">project<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><\/FONT><\/DIV>&nbsp;&nbsp;&nbsp; \u6bd4\u8f83app\u4e0ewebapp\u4e2d\u7684POM\uff0c\u9664\u524d\u9762\u5df2\u7ecf\u63d0\u8fc7\u7684packaging\u7684\u5dee\u522b\u5916\uff0c\u6211\u4eec\u8fd8\u53ef\u4ee5\u53d1\u73b0webapp\u4e2d\u7684POM\u591a\u4e86dependencies\u9879\u3002\u7531\u4e8ewebapp\u9700\u8981\u7528\u5230app\u5de5\u7a0b\u4e2d\u7684\u7c7b(\u89c1HelloServlet\u6e90\u4ee3\u7801)\uff0c\u5b83\u8fd8\u9700\u8981javax.servlet\u5305(\u56e0\u4e3a\u8be5\u5305\u5e76\u4e0d\u9ed8\u8ba4\u5b58\u5728\u4e8ejsdk\u4e2d)\u3002\u6545\uff0c\u6211\u4eec\u5fc5\u987b\u8981\u5c06\u5b83\u4eec\u58f0\u660e\u5230\u4f9d\u8d56\u5173\u7cfb\u4e2d\u3002<BR><STRONG>5.5 \u6267\u884c<\/STRONG><BR>&nbsp;&nbsp;&nbsp; \u4e0a\u8ff0\u4e24\u4e2a\u5de5\u7a0b\u521b\u5efa\u5b8c\u6bd5\u540e\uff0c\u5c31\u9700\u8981\u6267\u884c\u4e00\u4e9b\u547d\u4ee4\u6765\u770b\u770b\u4f1a\u6709\u4ec0\u4e48\u7ed3\u679c\u51fa\u73b0\u3002\u6211\u4eec\u9996\u5148\u8fdb\u5165app\u76ee\u5f55\uff0c\u5e76\u6267\u884c\u547d\u4ee4<FONT color=#0000ff>mvn compile<\/FONT>\uff0c\u7136\u540e\u4f1a\u5728\u8be5\u76ee\u5f55\u4e0b\u53d1\u73b0\u65b0\u751f\u6210\u7684\u76ee\u5f55target\\classes\uff0c\u5373\u7f16\u8bd1\u540e\u7684class\u6587\u4ef6(\u5305\u62ec\u5b83\u7684\u5305\u76ee\u5f55)\u5c31\u653e\u5728\u4e86\u8fd9\u91cc\u3002\u518d\u6267\u884c\u547d\u4ee4mvn package\uff0c\u5728\u76ee\u5f55target\u4e2d\u5c31\u4f1a\u751f\u6210app-1.0.jar\u6587\u4ef6\u3002\u8be5\u6587\u4ef6\u7684\u5168\u540d\u7531\u5982\u4e0b\u5f62\u5f0f\u786e\u5b9a\uff1a<STRONG>artifactId-version.packaging<\/STRONG>\u3002\u6839\u636e\u7b2c2\u7ae0\u7684\u53d9\u8ff0\u53ef\u4ee5\u77e5\u9053\uff0c\u6267\u884c\u547d\u4ee4<FONT color=#0000ff>mvn package<\/FONT>\u65f6\uff0c\u5c06\u9996\u5148\u5c06\u4ea7\u751f\u6267\u884c\u547d\u4ee4<FONT color=#0000ff>mvn compile<\/FONT>\u4e4b\u540e\u7684\u7ed3\u679c\uff0c\u6545\u5982\u679c\u8981\u6253\u5305\uff0c\u90a3\u4e48\u53ea\u9700\u8981\u6267\u884c<FONT color=#0000ff>mvn package<\/FONT>\u5373\u53ef\u3002<BR>&nbsp;&nbsp;&nbsp; \u5728app\u5de5\u7a0b\u4e2d\u6267\u884c\u5b8c\u4e4b\u540e\uff0c\u5c31\u9700\u8981\u8fdb\u5165webapp\u5de5\u7a0b\u4e86\u3002\u8fdb\u5165webapp\u76ee\u5f55\uff0c\u6b64\u6b21\u5c06\u53ea\u6267\u884c<FONT color=#0000ff>mvn package<\/FONT>\u547d\u4ee4(\u9690\u793a\u5730\u6267\u884c\u4e86compile\u8fc7\u7a0b)\u3002\u6b64\u6b21\u547d\u4ee4\u7684\u6267\u884c\u5e76\u4e0d\u6210\u529f\uff0c\u4f1a\u51fa\u73b0\u5982\u4e0b\u95ee\u9898\uff1a<BR><FONT color=#0000ff><br \/>\n<DIV style=\"BORDER-RIGHT: rgb(204,204,204) 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(204,204,204) 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: rgb(204,204,204) 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: rgb(204,204,204) 1px solid; BACKGROUND-COLOR: rgb(238,238,238)\"><!--\n\nCode highlighting produced by Actipro CodeHighlighter (freeware)<br \/><a href=\"http:\/\/www.CodeHighlighter.com\/\" target=\"_blank\">http:\/\/www.CodeHighlighter.com\/<\/a>\n\n--><FONT size=2><SPAN style=\"COLOR: rgb(0,0,0)\">D:\\maven\\demo\\webapp&gt;mvn&nbsp;package<BR>\u2026\u2026<BR><STRONG>Downloading:&nbsp;http:\/\/repo1.maven.org\/maven2\/ce\/demo\/mvn\/app\/<\/STRONG><\/SPAN><STRONG><SPAN style=\"COLOR: rgb(0,0,0)\">1.0<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">\/app-<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">1.0<\/SPAN><\/STRONG><\/FONT><FONT size=2><SPAN style=\"COLOR: rgb(0,0,0)\"><STRONG>.pom<\/STRONG><BR><\/SPAN><SPAN style=\"FONT-WEIGHT: bold; COLOR: rgb(128,0,0)\">[<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">INFO<\/SPAN><SPAN style=\"FONT-WEIGHT: bold; COLOR: rgb(128,0,0)\">]<\/SPAN><\/FONT><FONT size=2><SPAN style=\"COLOR: rgb(0,0,0)\">&nbsp;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<BR><\/SPAN><SPAN style=\"FONT-WEIGHT: bold; COLOR: rgb(128,0,0)\">[<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">ERROR<\/SPAN><SPAN style=\"FONT-WEIGHT: bold; COLOR: rgb(128,0,0)\">]<\/SPAN><\/FONT><FONT size=2><SPAN style=\"COLOR: rgb(0,0,0)\">&nbsp;BUILD&nbsp;ERROR<BR><\/SPAN><SPAN style=\"FONT-WEIGHT: bold; COLOR: rgb(128,0,0)\">[<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">INFO<\/SPAN><SPAN style=\"FONT-WEIGHT: bold; COLOR: rgb(128,0,0)\">]<\/SPAN><\/FONT><FONT size=2><SPAN style=\"COLOR: rgb(0,0,0)\">&nbsp;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<BR><\/SPAN><SPAN style=\"FONT-WEIGHT: bold; COLOR: rgb(128,0,0)\">[<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">INFO<\/SPAN><SPAN style=\"FONT-WEIGHT: bold; COLOR: rgb(128,0,0)\">]<\/SPAN><\/FONT><FONT size=2><SPAN style=\"COLOR: rgb(0,0,0)\">&nbsp;Error&nbsp;building&nbsp;POM&nbsp;(may&nbsp;not&nbsp;be&nbsp;this&nbsp;project&#8217;s&nbsp;POM).<BR>Project&nbsp;ID:&nbsp;ce.demo.mvn:app<BR>Reason:&nbsp;Error&nbsp;getting&nbsp;POM&nbsp;for&nbsp;&#8216;ce.demo.mvn:app&#8217;&nbsp;from&nbsp;the&nbsp;repository:&nbsp;Error&nbsp;transferring&nbsp;file<BR>&nbsp;&nbsp;ce.demo.mvn:app:pom:<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">1.0<\/SPAN><\/FONT><SPAN style=\"COLOR: rgb(0,0,0)\"><BR><FONT size=2>from&nbsp;the&nbsp;specified&nbsp;remote&nbsp;repositories:<BR>&nbsp;&nbsp;central&nbsp;(http:\/\/repo1.maven.org\/maven2)<BR>\u2026\u2026<\/FONT><\/SPAN><\/DIV><\/FONT>&nbsp;&nbsp;&nbsp; \u7531\u7c97\u4f53\u5185\u5bb9\u53ef\u77e5\uff0cMaven\u6b63\u8bd5\u56fe\u4ececentral\u4ed3\u5e93\u4e0b\u8f7dapp\u5de5\u7a0b\u7684artifact\uff0c\u4f46central\u4ed3\u5e93\u80af\u5b9a\u4e0d\u4f1a\u6709\u8fd9\u4e2aartifact\uff0c\u5176\u7ed3\u679c\u53ea\u80fd\u662f\u6267\u884c\u5931\u8d25!\u7531\u7b2c1\u7ae0artifact\u540d\u8bcd\u7684\u89e3\u91ca\u53ef\u77e5\uff0c\u88ab\u4f9d\u8d56\u7684artifact\u5fc5\u987b\u5b58\u5728\u4e8e\u4ed3\u5e93(\u8fdc\u7a0b\u6216\u672c\u5730)\u4e2d\uff0c\u4f46\u76ee\u524dwebapp\u6240\u4f9d\u8d56\u7684app\u5fc5\u4e0d\u5b58\u5728\u4e8e\u4ed3\u5e93\u4e2d\uff0c\u6240\u4ee5\u6267\u884c\u53ea\u80fd\u5931\u8d25\u3002<BR>&nbsp;&nbsp;&nbsp; \u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\u6709\u4e24\u79cd\u65b9\u6cd5\uff1a[1]\u5c06app-1.0.jar\u5b89\u88c5\u5230\u4ed3\u5e93\u4e2d\uff0c\u4f7f\u5b83\u6210\u4e3a\u4e00\u4e2aartifact\uff1b[2]\u6784\u5efa\u4e00\u4e2a\u66f4\u9ad8\u5c42\u6b21\u7684\u5de5\u7a0b\uff0c\u4f7fapp\u548cwebapp\u6210\u4e3a\u8fd9\u4e2a\u5de5\u7a0b\u7684\u5b50\u5de5\u7a0b\uff0c\u7136\u540e\u4ece\u8fd9\u4e2a\u66f4\u9ad8\u5c42\u6b21\u5de5\u7a0b\u4e2d\u6267\u884c\u547d\u4ee4\u3002<BR>&nbsp;&nbsp;&nbsp; \u7b2c\u4e00\u79cd\u65b9\u6cd5\u6bd4\u8f83\u7b80\u5355\uff08<FONT color=#0000ff><FONT color=#000000>\u89c1<\/FONT>http:\/\/www.blogjava.net\/jiangshachina\/admin\/EditPosts.aspx<FONT color=#000000>\u4e2d\u7684\u7b2c\u4e00\u4e2a\u4e3b\u9898<\/FONT><\/FONT>\uff09\uff0c\u6b64\u5904\u5c06\u8be6\u7ec6\u8ba8\u8bba\u7b2c2\u79cd\u65b9\u6cd5(\u89c15.6\u8282)\u3002<BR><STRONG>5.6 \u66f4\u9ad8\u5c42\u6b21\u5de5\u7a0b<\/STRONG><BR>&nbsp;&nbsp;&nbsp; \u6211\u4eec\u53ef\u4ee5\u5c06app\u548cwebapp\u7684\u4e0a\u4e00\u7ea7\u76ee\u5f55demo\u4f5c\u4e3a\u8fd9\u4e24\u4e2a\u5de5\u7a0b\u7684 \u4e00\u4e2a \u66f4\u9ad8\u5c42\u6b21\u5de5\u7a0b\uff0c\u5373\u4f7f\u7528app\u548cwebapp\u6210\u4e3a\u8fd9\u4e2a\u5de5\u7a0b\u7684\u5b50\u5de5\u7a0b\u3002\u4e3a\u4e86\u4f7fdemo\u76ee\u5f55\u6210\u4e3a\u4e00\u4e2ademo\u5de5\u7a0b\uff0c\u53ea\u9700\u8981\u5728\u8fd9\u4e2a\u76ee\u5f55\u4e0b\u6dfb\u52a0\u4e00\u4e2apom.xml\u6587\u4ef6\uff0c\u8be5\u6587\u4ef6\u5185\u5bb9\u5982\u4e0b\uff1a<BR><br \/>\n<DIV style=\"BORDER-RIGHT: rgb(204,204,204) 1px solid; PADDING-RIGHT: 5px; BORDER-TOP: rgb(204,204,204) 1px solid; PADDING-LEFT: 4px; FONT-SIZE: 13px; PADDING-BOTTOM: 4px; BORDER-LEFT: rgb(204,204,204) 1px solid; WIDTH: 98%; PADDING-TOP: 4px; BORDER-BOTTOM: rgb(204,204,204) 1px solid; BACKGROUND-COLOR: rgb(238,238,238)\"><FONT size=2><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/None.gif\" align=top _counted=\"undefined\"><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">project<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><\/FONT><SPAN style=\"COLOR: rgb(0,0,0)\"><BR><FONT size=2><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/None.gif\" align=top _counted=\"undefined\">&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><\/SPAN><FONT size=2><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">modelVersion<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">4.0.0<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;\/<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">modelVersion<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><\/FONT><SPAN style=\"COLOR: rgb(0,0,0)\"><BR><FONT size=2><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/None.gif\" align=top _counted=\"undefined\">&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><\/SPAN><FONT size=2><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">groupId<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">ce.demo<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;\/<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">groupId<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><\/FONT><SPAN style=\"COLOR: rgb(0,0,0)\"><BR><FONT size=2><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/None.gif\" align=top _counted=\"undefined\">&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><\/SPAN><FONT size=2><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">artifactId<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">mvn-demo<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;\/<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">artifactId<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><\/FONT><SPAN style=\"COLOR: rgb(0,0,0)\"><BR><FONT size=2><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/None.gif\" align=top _counted=\"undefined\">&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><\/SPAN><FONT size=2><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">packaging<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">pom<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;\/<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">packaging<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><\/FONT><SPAN style=\"COLOR: rgb(0,0,0)\"><BR><FONT size=2><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/None.gif\" align=top _counted=\"undefined\">&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><\/SPAN><FONT size=2><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">version<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">1.0<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;\/<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">version<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><\/FONT><SPAN style=\"COLOR: rgb(0,0,0)\"><BR><FONT size=2><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/None.gif\" align=top _counted=\"undefined\">&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><\/SPAN><FONT size=2><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">name<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">CE&nbsp;Maven&nbsp;Demo<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;\/<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">name<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><\/FONT><SPAN style=\"COLOR: rgb(0,0,0)\"><BR><FONT size=2><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/None.gif\" align=top _counted=\"undefined\">&nbsp;&nbsp;&nbsp;&nbsp;<BR><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/None.gif\" align=top _counted=\"undefined\">&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><\/SPAN><FONT size=2><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">modules<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><\/FONT><SPAN style=\"COLOR: rgb(0,0,0)\"><BR><FONT size=2><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/None.gif\" align=top _counted=\"undefined\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><\/SPAN><FONT size=2><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">module<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">app<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;\/<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">module<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><\/FONT><SPAN style=\"COLOR: rgb(0,0,0)\"><BR><FONT size=2><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/None.gif\" align=top _counted=\"undefined\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><\/SPAN><FONT size=2><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">module<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><SPAN style=\"COLOR: rgb(0,0,0)\">webapp<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;\/<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">module<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><\/FONT><SPAN style=\"COLOR: rgb(0,0,0)\"><BR><FONT size=2><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/None.gif\" align=top _counted=\"undefined\">&nbsp;&nbsp;&nbsp;&nbsp;<\/FONT><\/SPAN><FONT size=2><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;\/<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">modules<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><\/FONT><SPAN style=\"COLOR: rgb(0,0,0)\"><BR><FONT size=2><IMG alt=\"\" src=\"http:\/\/www.blogjava.net\/Images\/OutliningIndicators\/None.gif\" align=top _counted=\"undefined\"><\/FONT><\/SPAN><FONT size=2><SPAN style=\"COLOR: rgb(0,0,255)\">&lt;\/<\/SPAN><SPAN style=\"COLOR: rgb(128,0,0)\">project<\/SPAN><SPAN style=\"COLOR: rgb(0,0,255)\">&gt;<\/SPAN><\/FONT><\/DIV>&nbsp;&nbsp;&nbsp; \u4e0eapp\u548cwebapp\u4e2d\u7684POM\u76f8\u6bd4\uff0cdemo\u7684POM\u4f7f\u7528\u4e86modules\u9879\uff0cmodules\u7528\u4e8e\u58f0\u660e\u672c\u5de5\u7a0b\u7684\u5b50\u5de5\u7a0b\uff0cmodule\u4e2d\u7684\u503c\u5bf9\u5e94\u4e8e\u5b50\u5de5\u7a0b\u7684artifact\u540d\u3002\u800c\u4e14\u8be5POM\u7684packaging\u7c7b\u578b\u5fc5\u987b\u4e3apom\u3002<BR>&nbsp;&nbsp;&nbsp; \u6709\u4e86demo\u5de5\u7a0b\u540e\uff0c\u6211\u4eec\u53ea\u9700\u8981\u5728demo\u76ee\u5f55\u4e0b\u6267\u884c\u76f8\u5173\u547d\u4ee4\u5c31\u53ef\u4ee5\u4e86\u3002\u901a\u8fc7\u5982\u4e0b\u547d\u4ee4\u5373\u53ef\u9a8c\u8bc1\uff1a<BR>&nbsp;&nbsp;&nbsp; [1]<FONT color=#0000ff>mvn clean<\/FONT> \u2013 \u6d88\u9664\u5de5\u7a0b(\u5305\u62ec\u6240\u6709\u5b50\u5de5\u7a0b)\u4e2d\u4ea7\u751f\u7684\u6240\u6709\u8f93\u51fa\u3002\u8fd9\u672c\u6587\u7684\u5b9e\u4f8b\u4e2d\uff0c\u5b9e\u9645\u4e0a\u662f\u5220\u9664target\u76ee\u5f55\u3002\u7531\u4e8e\u4e4b\u524d\u7684\u64cd\u4f5c\u53ea\u6709app\u5de5\u7a0b\u4ea7\u751f\u4e86target\u76ee\u5f55\uff0c\u800cwebapp\u5e76\u6ca1\u6709\uff0c\u6240\u4ee5\u5c06\u53ea\u4f1a\u5220\u9664app\u5de5\u7a0b\u4e2d\u7684target\u76ee\u5f55\u3002<BR>&nbsp;&nbsp;&nbsp; [2]<FONT color=#0000ff>mvn package<\/FONT> \u2013 \u5c06\u5de5\u7a0b\u5236\u4f5c\u6210\u76f8\u5e94\u7684\u5305\uff0capp\u5de5\u7a0b\u662f\u4f5c\u6210jar\u5305(app-1.0.jar)\uff0cwebapp\u5de5\u7a0b\u662f\u4f5c\u6210war\u5305(webapp-1.0.war)\u3002\u6253\u5f00webapp-1.0.war\u5305\uff0c\u53ef\u4ee5\u53d1\u73b0app-1.0.jar\u88ab\u653e\u5230\u4e86WEB-INF\u7684lib\u76ee\u5f55\u4e2d\u3002<BR><STRONG>6 \u5c0f\u7ed3<\/STRONG><BR>&nbsp;&nbsp;&nbsp; \u901a\u8fc7\u4ee5\u4e0a\u7684\u53d9\u8ff0\u4e0e\u5b9e\u4f8b\uff0c\u5e94\u8be5\u53ef\u4ee5\u5bf9Maven\u6709\u4e00\u4e2a\u7c97\u7565\u7684\u8ba4\u8bc6\u4e86\u3002\u4f7f\u7528Maven\u5173\u952e\u662f\u8981\u5f04\u6e05\u695a\u5982\u4f55\u5199pom.xml\u6587\u4ef6\uff0c\u5c31\u5982\u540c\u4f7f\u7528Ant\u8981\u4f1a\u5199build.xml\u6587\u4ef6\u4e00\u6837\u3002\u5728POM\u4e2d\u53ef\u4ee5\u76f4\u63a5\u5199\u5165Ant\u7684task\u811a\u672c\uff0c\u4e5f\u53ef\u4ee5\u8c03\u7528Ant\u7684build.xml\u6587\u4ef6(\u63a8\u8350)\uff0c\u6240\u4ee5Maven\u4e5f\u53ef\u4ee5\u5b8c\u6210Ant\u7684\u7edd\u5927\u591a\u6570\u5de5\u4f5c(\u4f46\u4e0d\u5fc5\u5b89\u88c5Ant)\u3002\u6ce8\u610f\uff1a<STRONG>\u4f7f\u7528Maven\u5c31\u4e0d\u8981\u518d\u8fc7\u591a\u7684\u4f7f\u7528Ant\u811a\u672c<\/STRONG>\u3002<BR>&nbsp;&nbsp;&nbsp; \u5229\u7528\u597dMaven\u7684\u7ee7\u627f\u7279\u6027\u53ca\u5b50\u5de5\u7a0b\u7684\u5173\u7cfb\uff0c\u53ef\u4ee5\u5f88\u597d\u5730\u7b80\u5316POM\u6587\u4ef6\uff0c\u5e76\u80fd\u591f\u6784\u5efa\u5c42\u6b21\u7ed3\u6784\u826f\u597d\u7684\u5de5\u7a0b\uff0c\u6709\u5229\u4e8e\u5de5\u7a0b\u7684\u7ef4\u62a4\u3002<BR><STRONG>7 \u53c2\u8003\u8d44\u6e90<\/STRONG><BR>[1]Maven\u5b98\u65b9\u7f51\u7ad9. http:\/\/maven.apache.org<BR>[2]Maven POM\u6587\u4ef6\u53c2\u8003\u7ed3\u6784. http:\/\/maven.apache.org\/ref\/current\/maven-model\/maven.html<BR>[3]Super POM. http:\/\/maven.apache.org\/guides\/introduction\/introduction-to-the-pom.html<BR>[4]Maven\u4e3b\u8981\u63d2\u4ef6\u7684\u5217\u8868. http:\/\/maven.apache.org\/plugins<BR>[5]Maven\u57fa\u672c\u4f7f\u7528\u6307\u5357. http:\/\/maven.apache.org\/guides\/index.html<BR>[6]Better Build with Maven. http:\/\/www.mergere.com\/m2book_download.jsp &#8212; \u5f3a\u70c8\u63a8\u8350<BR>[7]\u4ecb\u7ecdMaven2. http:\/\/www.javaworld.com\/javaworld\/jw-12-2005 \/jw-1205-maven_p.html<BR>[8]\u63ed\u79d8Maven2 POM. http:\/\/www.javaworld.com\/javaworld\/jw-05-2006\/jw-0529-maven.html<BR>[9]Maven\u8ba9\u4e8b\u60c5\u53d8\u5f97\u7b80\u5355. http:\/\/www-128.ibm.com\/developerworks\/cn\/java\/j-maven<BR>[10]Maven\u6587\u6863\u96c6. http:\/\/docs.codehaus.org\/display\/MAVENUSER\/Home<BR>[11]\u6709\u6548\u5229\u7528Maven2\u7684\u7ad9\u70b9\u751f\u6210\u529f\u80fd. http:\/\/www.matrix.org.cn\/resource\/article\/44\/44491_Maven2.html<BR><STRONG>\u6587\u4e2d\u4f8b\u5b50\u7a0b\u5e8f\u4e0b\u8f7d\uff1a<A href=\"http:\/\/www.blogjava.net\/files\/jiangshachina\/maven.rar\"><FONT color=#108ac6>http:\/\/www.blogjava.net\/files\/jiangshachina\/maven.rar<\/FONT><\/A><\/STRONG><\/DIV><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Maven\u5165\u95e8&#8211;\u6982\u5ff5\u4e0e\u5b9e\u4f8b &nbsp;&nbsp;&nbsp; \u6700\u8fd1\u7531\u4e8e\u5de5\u4f5c\u539f\u56e0\u5728\u7814\u7a76\u3001\u5e94\u7528Maven\uff0c\u6709\u4e86\u4e00\u4e9b\u4f53\u4f1a\u5c31\u5199\u6210\u4e86\u6b64\u6587\u3002\u672c\u6587\u867d\u7136\u662fMaven2\u7684\u5165\u95e8\u6587\u7ae0\uff0c\u4f46\u5e76\u4e0d\u6d89\u53caMaven\u7684\u5386\u53f2\u3001\u4e0b\u8f7d\u4e0e\u5b89\u88c5\uff0c\u8fd9\u4e9b\u5185\u5bb9\u53ef\u4ee5\u5230Maven\u7684\u5b98\u65b9\u7f51\u7ad9\u4e0a\u4e86\u89e3\u3002\u672c\u6587\u4e3b\u8981\u662f\u5173\u6ce8Maven\u4e2d\u7684\u91cd\u8981\u6982\u5ff5\uff0c\u5e76\u4ee5\u4e00\u4e2a\u5b9e\u4f8b\u6765\u9610\u8ff0\u4f7f\u7528Maven\u7684\u57fa\u672c\u65b9\u6cd5\u3002\u6587\u672b\u6709\u4f8b\u5b50\u4ee3\u7801\u4e0b\u8f7d\u7684\u94fe\u63a5\u3002(2007.01.02\u6700\u540e\u66f4\u65b0) 1 \u5173\u952e\u540d\u8bcd &nbsp;&nbsp;&nbsp; Project\uff1a\u4efb\u4f55\u60a8\u60f3build\u7684\u4e8b\u7269\uff0cMaven\u90fd\u53ef\u4ee5\u8ba4\u4e3a\u5b83\u4eec\u662f\u5de5\u7a0b\u3002\u8fd9\u4e9b\u5de5\u7a0b\u88ab\u5b9a\u4e49\u4e3a\u5de5\u7a0b\u5bf9\u8c61\u6a21\u578b(POM\uff0cPoject Object Model)\u3002\u4e00\u4e2a\u5de5\u7a0b\u53ef\u4ee5\u4f9d\u8d56\u5176\u5b83\u7684\u5de5\u7a0b\uff1b\u4e00\u4e2a\u5de5\u7a0b\u4e5f\u53ef\u4ee5\u7531\u591a\u4e2a\u5b50\u5de5\u7a0b\u6784\u6210\u3002&nbsp;&nbsp;&nbsp; POM\uff1aPOM(pom.xml)\u662fMaven\u7684\u6838\u5fc3\u6587\u4ef6\uff0c\u5b83\u662f\u6307\u793aMaven\u5982\u4f55\u5de5\u4f5c\u7684\u5143\u6570\u636e\u6587\u4ef6\uff0c\u7c7b\u4f3c\u4e8eAnt\u4e2d\u7684build.xml\u6587\u4ef6\u3002POM\u6587\u4ef6\u4f4d\u4e8e\u6bcf\u4e2a\u5de5\u7a0b\u7684\u6839\u76ee\u5f55\u4e2d\u3002&nbsp;&nbsp;&nbsp; GroupId\uff1agroupId\u662f\u4e00\u4e2a\u5de5\u7a0b\u7684\u5728\u5168\u5c40\u4e2d\u552f\u4e00\u7684\u6807\u8bc6\u7b26\uff0c\u4e00\u822c\u5730\uff0c\u5b83\u5c31\u662f\u5de5\u7a0b\u540d\u3002groupId\u6709\u5229\u4e8e\u4f7f\u7528\u4e00\u4e2a\u5b8c\u5168\u7684\u5305\u540d\uff0c\u5c06\u4e00\u4e2a\u5de5\u7a0b\u4ece\u5176\u5b83\u6709\u7c7b\u4f3c\u540d\u79f0\u7684\u5de5\u7a0b\u91cc\u533a\u522b\u51fa\u6765\u3002&nbsp;&nbsp;&nbsp; Artifact\uff1aartifact\u662f\u5de5\u7a0b\u5c06\u8981\u4ea7\u751f\u6216\u9700\u8981\u4f7f\u7528\u7684\u6587\u4ef6\uff0c\u5b83\u53ef\u4ee5\u662fjar\u6587\u4ef6\uff0c\u6e90\u6587\u4ef6\uff0c\u4e8c\u8fdb\u5236\u6587\u4ef6\uff0cwar\u6587\u4ef6\uff0c\u751a\u81f3\u662fpom\u6587\u4ef6\u3002\u6bcf\u4e2aartifact\u90fd\u7531groupId\u548cartifactId\u7ec4\u5408\u7684\u6807\u8bc6\u7b26\u552f\u4e00\u8bc6\u522b\u3002\u9700\u8981\u88ab\u4f7f\u7528(\u4f9d\u8d56)\u7684artifact\u90fd\u8981\u653e\u5728\u4ed3\u5e93(\u89c1Repository)\u4e2d\uff0c\u5426\u5219Maven\u65e0\u6cd5\u627e\u5230(\u8bc6\u522b)\u5b83\u4eec\u3002&nbsp;&nbsp;&nbsp; Dependency\uff1a\u4e3a\u4e86\u80fd\u591fbuild\u6216\u8fd0\u884c\uff0c\u4e00\u4e2a\u5178\u578b\u7684Java\u5de5\u7a0b\u4f1a\u4f9d\u8d56\u5176\u5b83\u7684\u5305\u3002\u5728Maven\u4e2d\uff0c\u8fd9\u4e9b\u88ab\u4f9d\u8d56\u7684\u5305\u5c31\u88ab\u79f0\u4e3adependency\u3002dependency\u4e00\u822c\u662f\u5176\u5b83\u5de5\u7a0b\u7684artifact\u3002&nbsp;&nbsp;&nbsp; Plug-in\uff1aMaven\u662f\u7531\u63d2\u4ef6\u7ec4\u7ec7\u7684\uff0c\u5b83\u7684\u6bcf\u4e00\u4e2a\u529f\u80fd\u90fd\u662f\u7531\u63d2\u4ef6\u63d0\u4f9b\u7684\u3002\u63d2\u4ef6\u63d0\u4f9bgoal(\u7c7b\u4f3c\u4e8eAnt\u4e2d\u7684target)\uff0c\u5e76\u6839\u636e\u5728POM\u4e2d\u627e\u5230\u7684\u5143\u6570\u636e\u53bb\u5b8c\u6210\u5de5\u4f5c\u3002\u4e3b\u8981\u7684Maven\u63d2\u4ef6\u8981\u662f\u7531Java\u5199\u6210\u7684\uff0c\u4f46\u5b83\u4e5f\u652f\u6301\u7528Beanshell\u6216Ant\u811a\u672c\u5199\u6210\u7684\u63d2\u4ef6\u3002&nbsp;&nbsp;&nbsp; Repository\uff1a\u4ed3\u5e93\u7528\u4e8e\u5b58\u653eartifact\uff0c\u5b83\u53ef\u4ee5\u662f\u672c\u5730\u4ed3\u5e93\uff0c\u4e5f\u53ef\u4ee5\u662f\u8fdc\u7a0b\u4ed3\u5e93\u3002Maven\u6709\u4e00\u4e2a\u9ed8\u8ba4\u7684\u8fdc\u7a0b\u4ed3\u5e93&#8211;central\uff0c\u53ef\u4ee5\u4ecehttp:\/\/www.ibiblio.org\/maven2\/\u4e0b\u8f7d\u5176\u4e2d\u7684artifact\u3002\u5728Windows\u5e73\u53f0\u4e0a\uff0c\u672c\u5730\u4ed3\u5e93\u7684\u9ed8\u8ba4\u5730\u5740\u662fUser_Home\\.m2\\repository\u3002&nbsp;&nbsp;&nbsp; Snapshot\uff1a\u5de5\u7a0b\u4e2d\u53ef\u4ee5(\u4e5f\u5e94\u8be5)\u6709\u4e00\u4e2a\u7279\u6b8a\u7248\u672c\uff0c\u5b83\u7684\u7248\u672c\u53f7\u5305\u62ecSNAPSHOT\u5b57\u6837\u3002\u8be5\u7248\u672c\u53ef\u4ee5\u544a\u8bc9Maven\uff0c\u8be5\u5de5\u7a0b\u6b63\u5904\u4e8e\u5f00\u53d1\u9636\u6bb5\uff0c\u4f1a\u7ecf\u5e38\u66f4\u65b0(\u4f46\u8fd8\u672a\u53d1\u5e03)\u3002\u5f53\u5176\u5b83\u5de5\u7a0b\u4f7f\u7528\u6b64\u7c7b\u578b\u7248\u672c\u7684artifact\u65f6\uff0cMaven\u4f1a\u5728\u4ed3\u5e93\u4e2d\u5bfb\u627e\u8be5artifact\u7684\u6700\u65b0\u7248\u672c\uff0c\u5e76\u81ea\u52a8\u4e0b\u8f7d\u3001\u4f7f\u7528\u8be5\u6700\u65b0\u7248\u30022 Maven Build Life Cycle&nbsp;&nbsp;&nbsp; \u8f6f\u4ef6\u9879\u76ee\u4e00\u822c\u90fd\u6709\u76f8\u4f3c\u7684\u5f00\u53d1\u8fc7\u7a0b\uff1a\u51c6\u5907\uff0c\u7f16\u8bd1\uff0c\u6d4b\u8bd5\uff0c\u6253\u5305\u548c\u90e8\u7f72\uff0cMaven\u5c06\u4e0a\u8ff0\u8fc7\u7a0b\u79f0\u4e3aBuild Life Cycle\u3002\u5728Maven\u4e2d\uff0c\u8fd9\u4e9b\u751f\u547d\u5468\u671f\u7531\u4e00\u7cfb\u5217\u7684\u77ed\u8bed\u7ec4\u6210\uff0c\u6bcf\u4e2a\u77ed\u8bed\u5bf9\u5e94\u7740\u4e00\u4e2a(\u6216\u591a\u4e2a)\u64cd\u4f5c\uff1b\u6216\u5bf9\u5e94\u7740\u4e00\u4e2a(\u6216\u591a\u4e2a)goal(\u7c7b\u4f3c\u4e8eAnt\u4e2d\u7684target)\u3002&nbsp;&nbsp;&nbsp; \u5982\u7f16\u8bd1\u6e90\u6587\u4ef6\u7684\u547d\u4ee4mvn compile\u4e2d\u7684compile\u662f\u4e00\u4e2a\u751f\u547d\u5468\u671f\u77ed\u8bed\u3002\u540c\u65f6\u8be5\u547d\u4ee4\u4e5f\u53ef\u4ee5\u7b49\u4ef7\u4e8emvn compiler:compile\uff0c\u5176\u4e2d\u7684compiler\u662f\u4e00\u4e2a\u63d2\u4ef6\uff0c\u5b83\u63d0\u4f9b\u4e86compile(\u6b64compile\u4e0emvn compile\u4e2d\u7684compile\u610f\u4e49\u4e0d\u540c)goal\uff1bcompiler\u8fd8\u53ef\u63d0\u4f9b\u53e6\u4e00\u4e2agoal&#8211;testCompile\uff0c\u8be5goal\u7528\u4e8e\u7f16\u8bd1junit\u6d4b\u8bd5\u7c7b\u3002&nbsp;&nbsp;&nbsp; \u5728\u6267\u884c\u67d0\u4e00\u4e2a\u751f\u547d\u5468\u671f\u65f6\uff0cMaven\u4f1a\u9996\u5148\u6267\u884c\u8be5\u751f\u547d\u5468\u671f\u4e4b\u524d\u7684\u5176\u5b83\u5468\u671f\u3002\u5982\u8981\u6267\u884ccompile\uff0c\u90a3\u4e48\u5c06\u9996\u5148\u6267\u884cvalidate\uff0cgenerate-source\uff0cprocess-source\u548cgenerate-resources\uff0c\u6700\u540e\u518d\u6267\u884ccompile\u672c\u8eab\u3002\u5173\u4e8eMaven\u4e2d\u9ed8\u8ba4\u7684\u751f\u547d\u5468\u671f\u77ed\u8bed\uff0c\u8bf7\u89c1\u53c2\u8003\u8d44\u6e90[6]\u4e2d\u7684\u9644\u5f55B.3\u30023 \u6807\u51c6\u76ee\u5f55\u5e03\u5c40&nbsp;&nbsp;&nbsp; Maven\u4e3a\u5de5\u7a0b\u4e2d\u7684\u6e90\u6587\u4ef6\uff0c\u8d44\u6e90\u6587\u4ef6\uff0c\u914d\u7f6e\u6587\u4ef6\uff0c\u751f\u6210\u7684\u8f93\u51fa\u548c\u6587\u6863\u90fd\u5236\u5b9a\u4e86\u4e00\u4e2a\u6807\u51c6\u7684\u76ee\u5f55\u7ed3\u6784\u3002Maven\u9f13\u52b1\u4f7f\u7528\u6807\u51c6\u76ee\u5f55\u5e03\u5c40\uff0c\u8fd9\u6837\u5c31\u4e0d\u9700\u8981\u8fdb\u884c\u989d\u5916\u7684\u914d\u7f6e\uff0c\u800c\u4e14\u6709\u52a9\u4e8e\u5404\u4e2a\u4e0d\u540c\u5de5\u7a0b\u4e4b\u95f4\u7684\u8054\u63a5\u3002\u5f53\u7136\uff0cMaven\u4e5f\u5141\u8bb8\u5b9a\u5236\u4e2a\u6027\u7684\u76ee\u5f55\u5e03\u5c40\uff0c\u8fd9\u5c31\u9700\u8981\u8fdb\u884c\u66f4\u591a\u7684\u914d\u7f6e\u3002\u5173\u4e8eMaven\u7684\u6807\u51c6\u76ee\u5f55\u5e03\u5c40\uff0c\u8bf7\u89c1\u53c2\u8003\u8d44\u6e90[6]\u4e2d\u7684\u9644\u5f55B.1\u30024 Maven\u7684\u4f18\u70b9&nbsp;&nbsp;&nbsp; [1]build\u903b\u8f91\u53ef\u4ee5\u88ab\u91cd\u7528\u3002\u5728Ant\u4e2d\u53ef\u80fd\u9700\u8981\u591a\u6b21\u91cd\u590d\u5730\u5199\u76f8\u540c\u7684\u8bed\u53e5\uff0c\u4f46\u7531\u4e8ePOM\u7684\u7ee7\u627f\u6027\uff0c\u53ef\u4ee5\u590d\u7528\u5176\u5b83\u7684POM\u6587\u4ef6\u4e2d\u7684\u8bed\u53e5\u3002\u8fd9\u6837\u65e2\u53ef\u4ee5\u5199\u51fa\u6e05\u6670\u7684build\u8bed\u53e5\uff0c\u53c8\u53ef\u4ee5\u6784\u9020\u51fa\u5c42\u6b21\u5173\u7cfb\u826f\u597d\u7684build\u5de5\u7a0b\u3002&nbsp;&nbsp;&nbsp; [2]\u4e0d\u5fc5\u5173\u6ce8build\u5de5\u4f5c\u7684\u5b9e\u73b0\u7ec6\u8282\u3002\u6211\u4eec\u53ea\u9700\u8981\u4f7f\u7528\u4e00\u4e9bbuild\u751f\u547d\u5468\u671f\u77ed\u8bed\u5c31\u53ef\u4ee5\u8fbe\u5230\u6211\u4eec\u7684\u76ee\u6807\uff0c\u800c\u4e0d\u5fc5\u7ba1Maven\u662f\u5982\u4f55\u505a\u5230\u8fd9\u4e9b\u7684\u3002\u5982\uff0c\u53ea\u9700\u8981\u544a\u8bc9Maven\u8981\u5b89\u88c5(install)\uff0c\u90a3\u4e48\u5b83\u81ea\u7136\u5c31\u4f1a\u9a8c\u8bc1\uff0c\u7f16\u8bd1\uff0c\u6253\u5305\uff0c\u53ca\u5b89\u88c5\u3002&nbsp;&nbsp;&nbsp; [3]Maven\u4f1a\u81ea\u52a8\u52a0\u8f7d\u5de5\u7a0b\u4f9d\u8d56\u7684artifact\u6240\u4f9d\u8d56\u7684\u5176\u5b83artifact(Transitive Dependency)\uff0c\u800c\u4e0d\u7528\u663e\u793a\u7684\u5c06\u8fd9\u4e9bartifact\u5168\u90e8\u5199\u5230dependency\u4e2d\u3002&nbsp;&nbsp;&nbsp; [4]\u5982\u679c\u5b8c\u5168\u4f7f\u7528Maven\u7684\u6807\u51c6\u76ee\u5f55\u5e03\u5c40\uff0c\u90a3\u4e48\u53ef\u4ee5\u6781\u5927\u5730\u51cf\u5c11\u914d\u7f6e\u7ec6\u8282\u30025 \u5b9e\u4f8b5.1 \u6784\u60f3&nbsp;&nbsp;&nbsp; \u7531\u4e8e\u53ea\u662f\u9610\u8ff0Maven\u7684\u57fa\u672c\u4f7f\u7528\u65b9\u6cd5\uff0c\u6240\u4ee5\u672c\u6587\u5c06\u8981\u8bbe\u8ba1\u7684\u5b9e\u4f8b\uff0c\u53ea\u662f\u4e00\u4e2a\u7b80\u5355\u7684Maven demo\u3002\u8be5\u5b9e\u4f8b\u5305\u542b\u4e24\u4e2a\u5de5\u7a0b\uff1a\u666e\u901a\u5e94\u7528\u7a0b\u5e8f\u5de5\u7a0b(app)\u548cWeb\u5e94\u7528\u5de5\u7a0b(webapp)\u3002app\u5de5\u7a0b\u63d0\u4f9b\u4e00\u4e2a\u7b80\u5355\u7684Java\u7c7b\uff1bwebapp\u5de5\u7a0b\u53ea\u5305\u542b\u4e00\u4e2aServlet\uff0c\u5e76\u5c06\u4f7f\u7528app\u4e2d\u7684Java\u7c7b\u3002&nbsp;&nbsp;&nbsp; \u8be5Demo\u7684\u76ee\u6807\u662f\u80fd\u591f\u6b63\u786e\u5730\u5c06webapp\u5236\u6210war\u5305\uff0c\u4ee5\u4f9b\u90e8\u7f72\u65f6\u4f7f\u7528\u3002\u8981\u80fd\u591f\u6b63\u786e\u5236\u4f5cwar\uff0c\u81ea\u7136\u9996\u5148\u5c31\u5fc5\u987b\u8981\u80fd\u591f\u6b63\u786e\u7684\u7f16\u8bd1\u6e90\u4ee3\u7801\uff0c\u4e14\u8981\u5c06App\u6a21\u5757\u5236\u6210jar\u5305\u3002\u672c\u6587\u521b\u5efa\u7684\u5de5\u7a0b\u6240\u5728\u7684\u76ee\u5f55\u662fD:\\maven\\demo\u30025.2 App\u5de5\u7a0b&nbsp;&nbsp;&nbsp; \u53ef\u4ee5\u4f7f\u7528Maven\u7684archetype\u63d2\u4ef6\u6765\u521b\u5efa\u65b0\u5de5\u7a0b\uff0c\u547d\u4ee4\u5982\u4e0b\uff1a&nbsp;&nbsp;&nbsp; D:\\maven\\demo&gt;mvn archetype:create -DgroupId=ce.demo.mvn -DartifactId=app\u8be5\u5de5\u7a0b\u7684groupId\u662fce.demo.mvn\uff0c\u90a3\u4e48\u8be5\u5de5\u7a0b\u7684\u6e90\u6587\u4ef6\u5c06\u653e\u5728Java\u5305ce.demo.mvn\u4e2d\u3002artifactId\u662fapp\uff0c\u90a3\u4e48\u8be5\u5de5\u7a0b\u6839\u76ee\u5f55\u7684\u540d\u79f0\u5c06\u4e3aapp\u3002&nbsp;&nbsp;&nbsp; \u5f53\u7b2c\u4e00\u6b21\u6267\u884c\u8be5\u547d\u4ee4\u65f6\uff0cMaven\u4f1a\u4ececentral\u4ed3\u5e93\u4e2d\u4e0b\u8f7d\u4e00\u4e9b\u6587\u4ef6\u3002\u8fd9\u4e9b\u6587\u4ef6\u5305\u542b\u63d2\u4ef6archetype\uff0c\u4ee5\u53ca\u5b83\u6240\u4f9d\u8d56\u7684\u5176\u5b83\u5305\u3002\u8be5\u547d\u4ee4\u6267\u884c\u5b8c\u6bd5\u540e\uff0c\u5728\u76ee\u5f55D:\\maven\\demo\u4e0b\u4f1a\u51fa\u73b0\u5982\u4e0b\u76ee\u5f55\u5e03\u5c40\uff1a app|&#8211;&nbsp;pom.xml`&#8211;&nbsp;src&nbsp;&nbsp;&nbsp;&nbsp;|&#8211;&nbsp;main&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;`&#8211;&nbsp;java&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`&#8211;&nbsp;ce&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`&#8211;&nbsp;demo&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`&#8211;&nbsp;mvn&nbsp;&nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`&#8211;&nbsp;App.java&nbsp;&nbsp;&nbsp;&nbsp;`&#8211;&nbsp;test&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`&#8211;&nbsp;java&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`&#8211;&nbsp;ce&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`&#8211;&nbsp;demo&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`&#8211;&nbsp;mvn&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;`&#8211;&nbsp;AppTest.java\u56e0\u672c\u6587\u6682\u65f6\u4e0d\u6d89\u53caJUnit\u6d4b\u8bd5\uff0c\u6545\u8bf7\u5c06\u76ee\u5f55app\\src\\test\u76ee\u5f55\u5220\u9664(\u4e0d\u5220\u9664\u4e5f\u6ca1\u5173\u7cfb ^_^)\u3002\u7136\u540e\u518d\u4fee\u6539App.java\u6587\u4ef6\uff0c\u5176\u5b8c\u5168\u5185\u5bb9\u5982\u4e0b\uff1a package&nbsp;ce.demo.mvn;public&nbsp;class&nbsp;App&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;public&nbsp;String&nbsp;getStr(String&nbsp;str)&nbsp;{&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return&nbsp;str;&nbsp;&nbsp;&nbsp;&nbsp;}}\u5176\u5b9e\uff0c\u5982\u679c\u6211\u4eec\u80fd\u591f\u6e05\u695a\u5730\u77e5\u9053Maven\u7684\u6807\u51c6\u76ee\u5f55\u5e03\u5c40\uff0c\u5c31\u53ef\u4ee5\u4e0d\u4f7f\u7528archetype\u63d2\u4ef6\u6765\u521b\u5efa\u5de5\u7a0b\u539f\u578b\uff1b\u5982\u679c\u6211\u4eec\u8981\u5b9a\u5236\u4e2a\u6027\u7684\u76ee\u5f55\u5e03\u5c40\uff0c\u90a3\u4e48\u5c31\u66f4\u6ca1\u6709\u5fc5\u8981\u4f7f\u7528archetype\u63d2\u4ef6\u4e86\u30025.3 WebApp\u5de5\u7a0b&nbsp;&nbsp;&nbsp; \u6211\u4eec\u4ecd\u7136\u5982\u521b\u5efaapp\u5de5\u7a0b\u4e00\u6837\u4f7f\u7528archetype\u63d2\u4ef6\u6765\u521b\u5efawebapp\u5de5\u7a0b\uff0c\u547d\u4ee4\u5982\u4e0b\uff1a&nbsp;&nbsp;&nbsp; D:\\maven\\demo&gt;mvn archetype:create &hellip; <a href=\"https:\/\/www.strongd.net\/?p=533\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Maven\u5165\u95e8&#8211;\u6982\u5ff5\u4e0e\u5b9e\u4f8b<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-533","post","type-post","status-publish","format-standard","hentry","category-java"],"_links":{"self":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts\/533","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=533"}],"version-history":[{"count":1,"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts\/533\/revisions"}],"predecessor-version":[{"id":833,"href":"https:\/\/www.strongd.net\/index.php?rest_route=\/wp\/v2\/posts\/533\/revisions\/833"}],"wp:attachment":[{"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=533"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=533"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.strongd.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=533"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}