﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>BlogJava-自然-文章分类-Construct</title><link>http://www.blogjava.net/masen/category/45284.html</link><description /><language>zh-cn</language><lastBuildDate>Wed, 09 Jun 2010 11:53:32 GMT</lastBuildDate><pubDate>Wed, 09 Jun 2010 11:53:32 GMT</pubDate><ttl>60</ttl><item><title>Maven2（初-转IBM）</title><link>http://www.blogjava.net/masen/articles/323129.html</link><dc:creator>Masen</dc:creator><author>Masen</author><pubDate>Wed, 09 Jun 2010 03:14:00 GMT</pubDate><guid>http://www.blogjava.net/masen/articles/323129.html</guid><wfw:comment>http://www.blogjava.net/masen/comments/323129.html</wfw:comment><comments>http://www.blogjava.net/masen/articles/323129.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.blogjava.net/masen/comments/commentRss/323129.html</wfw:commentRss><trackback:ping>http://www.blogjava.net/masen/services/trackbacks/323129.html</trackback:ping><description><![CDATA[<blockquote style="font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; ">本文主要阐述 Maven2 的新特性，这些新特性可以大大地缩短了开发管理中的工作量，使得开发人员将精力集中在实际的业务问题上。</blockquote>
<p style="padding-bottom: 8px; padding-top: 5px; margin-top: 0px; margin-bottom: 0px; font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; ">Maven 出现到现在也有很长时间了，初识它的感觉至今仍清晰的印在脑海中。现在想来，当时从 Ant 移情 Maven 的想法其实很朴素，就是因为 Maven 可以以网站的形式展现与项目相关的信息，如开发人员列表、各种 Report。这种方式为项目的构建带来了极大的方便，尤其是 Report 的。试想对于产生的 Junit-Report、JavaDoc、CheckStyle、PMD 等报告，如果没有一个统一的入口，每次切换目录是多么令人厌烦的事情！</p>
<p style="padding-bottom: 8px; padding-top: 5px; margin-top: 0px; margin-bottom: 0px; font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; ">Maven 无疑是相当成功的，这一点从越来越多的开源项目开始使用 Maven 就可以看出。Maven 取得成功的原因很简单：在简化构建脚本的同时，功能并没有缩水，反而有所增强；提供汇集项目信息的工具，并以相当友好的方式呈现；丰富的插件简化了工作。如此有力的工具出现，自然是争相使用。</p>
<p style="padding-bottom: 8px; padding-top: 5px; margin-top: 0px; margin-bottom: 0px; font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; "><a name="N1005E"><span class="atitle" style="font-family: Arial, sans-serif; font-weight: bold; font-size: 18px; ">新特性</span></a></p>
<p style="padding-bottom: 8px; padding-top: 5px; margin-top: 0px; margin-bottom: 0px; font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; ">如今 Maven2 已经推出，Maven 的官方网站称，Maven2 相对于 Maven1 是一个相当大的转变，甚至不惜牺牲兼容性来达到这一目的。（为了 Maven1 的用户着想，Maven1 仍在继续他的使命。）如此大的变动到底换来了什么样的结果？</p>
<p style="padding-bottom: 8px; padding-top: 5px; margin-top: 0px; margin-bottom: 0px; font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; "><a name="N10067"><span class="smalltitle" style="font-family: arial, nsimsun, sans-serif; font-weight: bold; font-size: 15px; ">1．	更快、更简单</span></a></p>
<p style="padding-bottom: 8px; padding-top: 5px; margin-top: 0px; margin-bottom: 0px; font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; ">比起 Maven1 那不急不慢的运行速度，Maven2在速度上有了质的飞跃，甚至与Ant相比也毫不逊色（当然，下载不算）。除此之外，"简化工作，使用业界公认的最佳实践"也是是 Maven2 的另一大主题，其他的新特性无处不在体现 Maven2 为简化工作而做出的努力。</p>
<p style="padding-bottom: 8px; padding-top: 5px; margin-top: 0px; margin-bottom: 0px; font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; "><a name="N10070"><span class="smalltitle" style="font-family: arial, nsimsun, sans-serif; font-weight: bold; font-size: 15px; ">2．	更少的配置文件</span></a></p>
<p style="padding-bottom: 8px; padding-top: 5px; margin-top: 0px; margin-bottom: 0px; font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; ">Maven1 和 Maven2 主要配置文件的对比：</p>
<ul style="margin-top: 2px; margin-bottom: 2px; padding-top: 2px; padding-bottom: 2px; font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; ">
    <li>Maven1：project.xml、maven.xml、project.properties和build.properties。</li>
    <li>Maven2：pom.xml和settings.xml。</li>
</ul>
<p style="padding-bottom: 8px; padding-top: 5px; margin-top: 0px; margin-bottom: 0px; font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; ">POM是Maven的核心对象模型，在Maven2中POM已由project.xml转移到pom.xml中使用，版本也由3升级为4。对于项目，一般只需要pom.xml就行了。</p>
<p style="padding-bottom: 8px; padding-top: 5px; margin-top: 0px; margin-bottom: 0px; font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; ">在Maven2中不需要也不提倡使用maven.xml，原因如下：</p>
<ul style="margin-top: 2px; margin-bottom: 2px; padding-top: 2px; padding-bottom: 2px; font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; ">
    <li>plugin的易用性的增强。</li>
    <li>散布于maven.xml中的内容难以在不同项目间共享，也不利于维护。在Maven2中建议使用自定义的plugin来封装这些内容。</li>
</ul>
<p style="padding-bottom: 8px; padding-top: 5px; margin-top: 0px; margin-bottom: 0px; font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; ">如果仍期望能够使用类似maven.xml的功能，如&lt;preGoal&gt;，请参考<a href="http://docs.codehaus.org/display/MAVEN/Maven2+Goal+Decoration" style="color: #5c81a7; ">Inserting non-standard build steps using preGoals and postGoals。</a></p>
<p style="padding-bottom: 8px; padding-top: 5px; margin-top: 0px; margin-bottom: 0px; font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; ">在Maven2中，配置使用settings.xml，它取代了原有的project.properties和build.properties。配置在Maven2中存在两种级别：</p>
<ul style="margin-top: 2px; margin-bottom: 2px; padding-top: 2px; padding-bottom: 2px; font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; ">
    <li>用户级，针对操作系统登录用户而言。一般在$home/.m2/，对于windows用户，就是目录：C:\Documents and Settings\用户名\.m2\settings.xml。</li>
    <li>全局级：一般在%M2_HOME%/conf/settings.xml，M2_HOME是Maven2的根目录环境变量名。</li>
</ul>
<p style="padding-bottom: 8px; padding-top: 5px; margin-top: 0px; margin-bottom: 0px; font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; ">在settings.xml中可以配置，如本地Repository、proxy等等，关于settings.xml的结构可以从Maven的官方网站上获取。</p>
<p style="padding-bottom: 8px; padding-top: 5px; margin-top: 0px; margin-bottom: 0px; font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; "><a name="N100A6"><span class="smalltitle" style="font-family: arial, nsimsun, sans-serif; font-weight: bold; font-size: 15px; ">3．	Plugin语言更换</span></a></p>
<p style="padding-bottom: 8px; padding-top: 5px; margin-top: 0px; margin-bottom: 0px; font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; ">在Maven2中，编写plugin的语言由jelly变更为Java和BeanShell。Java在速度上更有优势，而且开发人员的熟悉程度更高。对于其他的流行脚本，如groovy，Maven的官方网站的意见是，等待其更成熟时再考虑</p>
<span  style="font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; ">。</span>
<p style="padding-bottom: 8px; padding-top: 5px; margin-top: 0px; margin-bottom: 0px; font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; "><a name="N100AF"><span class="smalltitle" style="font-family: arial, nsimsun, sans-serif; font-weight: bold; font-size: 15px; ">4．	提供预定义的目录模板</span></a></p>
<p style="padding-bottom: 8px; padding-top: 5px; margin-top: 0px; margin-bottom: 0px; font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; ">好的目录结构可以使开发人员更容易理解项目，为以后的维护工作也打下良好的基础。Maven2根据业界公认的最佳目录结构，为开发者提供了缺省的标准目录模板。Maven2的标准目录结构如下：</p>
<span  style="font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; "><br />
</span><span  style="font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; "><img alt="" border="0" height="581" src="http://www.ibm.com/developerworks/cn/opensource/os-maven2/images/table1.gif" width="319" /></span><span  style="font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; ">&nbsp;</span><span  style="font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; "><br />
</span>
<p style="padding-bottom: 8px; padding-top: 5px; margin-top: 0px; margin-bottom: 0px; font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; ">使用目录模板，可以使pom.xml更简洁。因为Maven2已经根据缺省目录，预定义了相关的动作，而无需人工的干预。以resources目录为例：</p>
<ul style="margin-top: 2px; margin-bottom: 2px; padding-top: 2px; padding-bottom: 2px; font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; ">
    <li>src/main/resources，负责管理项目主体的资源。在使用Maven2执行compile之后，这个目录中的所有文件及子目录，会复制到target/classes目录中，为以后的打包提供了方便。</li>
    <li>src/test/resources，负责管理项目测试的资源。在使用Maven2执行test-compile之后，这个目录中的所有文件及子目录，会复制到target/test-classes目录中，为后续的测试做好了准备。</li>
</ul>
<p style="padding-bottom: 8px; padding-top: 5px; margin-top: 0px; margin-bottom: 0px; font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; ">这些动作在 Maven1 中，是需要在 maven.xml 中使用&lt;preGoal&gt;或&lt;postGoal&gt;来完成的。如今，完全不需要在pom.xml中指定就能够自动完成。在src和test都使用resources，方便构建和测试，这种方式本就已是前人的经验。通过使用Maven2，使这个经验在开发团队中得到普及。</p>
<p style="padding-bottom: 8px; padding-top: 5px; margin-top: 0px; margin-bottom: 0px; font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; ">创建标准目录模板，可以通过如下命令：</p>
<span  style="font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; "><br />
</span>
<table width="100%" cellpadding="0" cellspacing="0" border="0" style="font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; ">
    <tbody>
        <tr>
            <td class="code-outline" style="line-height: 19px; background-color: #eeeeee; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; ">
            <pre class="displaycode" style="margin-top: 0px; margin-bottom: 0px; font-family: 'Andale Mono', 'Lucida Console', Monaco, fixed, monospace; font-size: 11px; ">mvn archetype:create -DgroupId=com.codeline.commons -DartifactId=codelineCommons
            </pre>
            </td>
        </tr>
    </tbody>
</table>
<span  style="font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; "><br />
</span>
<p style="padding-bottom: 8px; padding-top: 5px; margin-top: 0px; margin-bottom: 0px; font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; ">groupId和artifactId的含义与Maven1中的含义一样，参数artifactId的值会作为项目根目录的名字。除了建立相应的目录之外，Maven2还会创建缺省的pom.xml。</p>
<p style="padding-bottom: 8px; padding-top: 5px; margin-top: 0px; margin-bottom: 0px; font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; ">Maven2也考虑到：不同类型的项目需要拥有不同的目录结构。如创建web项目，可以使用命令：</p>
<span  style="font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; "><br />
</span>
<table width="100%" cellpadding="0" cellspacing="0" border="0" style="font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; ">
    <tbody>
        <tr>
            <td class="code-outline" style="line-height: 19px; background-color: #eeeeee; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; ">
            <pre class="displaycode" style="margin-top: 0px; margin-bottom: 0px; font-family: 'Andale Mono', 'Lucida Console', Monaco, fixed, monospace; font-size: 11px; ">mvn archetype:create -DgroupId=com.mycompany.app
            -DartifactId=my-webapp
            -DarchetypeArtifactId=maven-archetype-webapp
            </pre>
            </td>
        </tr>
    </tbody>
</table>
<span  style="font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; "><br />
</span>
<p style="padding-bottom: 8px; padding-top: 5px; margin-top: 0px; margin-bottom: 0px; font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; "><a name="N100F3"><span class="smalltitle" style="font-family: arial, nsimsun, sans-serif; font-weight: bold; font-size: 15px; ">5．	生命周期的引入</span></a></p>
<p style="padding-bottom: 8px; padding-top: 5px; margin-top: 0px; margin-bottom: 0px; font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; ">在Maven2中有了明确的生命周期概念，而且都提供与之对应的命令，使得项目构建更加清晰明了。主要的生命周期阶段：</p>
<ul style="margin-top: 2px; margin-bottom: 2px; padding-top: 2px; padding-bottom: 2px; font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; ">
    <li>validate，验证工程是否正确，所有需要的资源是否可用。</li>
    <li>compile，编译项目的源代码。</li>
    <li>test-compile，编译项目测试代码。</li>
    <li>test，使用已编译的测试代码，测试已编译的源代码。</li>
    <li>package，已发布的格式，如jar，将已编译的源代码打包。</li>
    <li>integration-test，在集成测试可以运行的环境中处理和发布包。</li>
    <li>verify，运行任何检查，验证包是否有效且达到质量标准。</li>
    <li>install，把包安装在本地的repository中，可以被其他工程作为依赖来使用</li>
    <li>deploy，在整合或者发布环境下执行，将最终版本的包拷贝到远程的repository，使得其他的开发者或者工程可以共享。</li>
    <li>generate-sources，产生应用需要的任何额外的源代码，如xdoclet。</li>
</ul>
<p style="padding-bottom: 8px; padding-top: 5px; margin-top: 0px; margin-bottom: 0px; font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; ">如果要执行项目编译，那么直接输入：mvn compile即可，对于其他的阶段可以类推。阶段之间是存在依赖关系（dependency）的，如test依赖test-compile。在执行mvn test时，会先运行mvn test-compile，然后才是mvn test。</p>
<p style="padding-bottom: 8px; padding-top: 5px; margin-top: 0px; margin-bottom: 0px; font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; "><a name="N10120"><span class="smalltitle" style="font-family: arial, nsimsun, sans-serif; font-weight: bold; font-size: 15px; ">6．	新增Dependency Scope</span></a></p>
<p style="padding-bottom: 8px; padding-top: 5px; margin-top: 0px; margin-bottom: 0px; font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; ">在POM 4中，&lt;dependency&gt;中还引入了&lt;scope&gt;，它主要管理依赖的部署。目前&lt;scope&gt;可以使用5个值：</p>
<ul style="margin-top: 2px; margin-bottom: 2px; padding-top: 2px; padding-bottom: 2px; font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; ">
    <li>compile，缺省值，适用于所有阶段，会随着项目一起发布。</li>
    <li>provided，类似compile，期望JDK、容器或使用者会提供这个依赖。如servlet.jar。</li>
    <li>runtime，只在运行时使用，如JDBC驱动，适用运行和测试阶段。</li>
    <li>test，只在测试时使用，用于编译和运行测试代码。不会随项目发布。</li>
    <li>system，类似provided，需要显式提供包含依赖的jar，Maven不会在Repository中查找它。</li>
</ul>
<p style="padding-bottom: 8px; padding-top: 5px; margin-top: 0px; margin-bottom: 0px; font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; ">&lt;scope&gt;的使用举例：</p>
<span  style="font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; "><br />
</span>
<table width="100%" cellpadding="0" cellspacing="0" border="0" style="font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; ">
    <tbody>
        <tr>
            <td class="code-outline" style="line-height: 19px; background-color: #eeeeee; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; ">
            <pre class="displaycode" style="margin-top: 0px; margin-bottom: 0px; font-family: 'Andale Mono', 'Lucida Console', Monaco, fixed, monospace; font-size: 11px; ">&lt;dependency&gt;
            &lt;groupId&gt;hibernate&lt;/groupId&gt;
            &lt;artifactId&gt;hibernate&lt;/artifactId&gt;
            &lt;version&gt;3.0.3&lt;/version&gt;
            &lt;scope&gt;test&lt;/scope&gt;
            &lt;/dependency&gt;
            </pre>
            </td>
        </tr>
    </tbody>
</table>
<span  style="font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; "><br />
</span>
<p style="padding-bottom: 8px; padding-top: 5px; margin-top: 0px; margin-bottom: 0px; font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; "><a name="N10147"><span class="smalltitle" style="font-family: arial, nsimsun, sans-serif; font-weight: bold; font-size: 15px; ">7．	传递依赖，简化依赖管理</span></a></p>
<p style="padding-bottom: 8px; padding-top: 5px; margin-top: 0px; margin-bottom: 0px; font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; ">在Maven1中，需要把依赖所需要的包也一并列出。这对于使用类似如Hibernate的用户来说所操的心太多了，而且也不方便。在Maven2中实现了传递依赖，如此对于Hibernate所依赖的包，Maven2会自动下载，开发人员只需关心Hibernate即可。</p>
<p style="padding-bottom: 8px; padding-top: 5px; margin-top: 0px; margin-bottom: 0px; font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; ">注意：只有得到Maven支持的依赖，通常是plugin形式出现，才能获得这个特性。而且对于一些老的plugin，可能由于时间的关系不支持传递依赖。如至少在Maven 2.0.1中，对于Hibernate 2.1.2，仍然需要显式列出Hibernate 2.1.2所依赖的包。</p>
<span  style="font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; "><br />
</span>
<table border="0" cellspacing="0" cellpadding="0" width="100%" style="font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; ">
    <tbody>
        <tr>
            <td style="line-height: 19px; "><img width="100%" src="http://www.ibm.com/i/v14/rules/blue_rule.gif" height="1" alt="" /><br />
            <img alt="" width="8" height="6" border="0" src="http://www.ibm.com/i/c.gif" /></td>
        </tr>
    </tbody>
</table>
<table class="no-print" cellspacing="0" cellpadding="0" align="right" style="font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; ">
    <tbody>
        <tr align="right">
            <td style="line-height: 19px; "><img width="100%" height="4" src="http://www.ibm.com/i/c.gif" alt="" /><br />
            <table border="0" cellpadding="0" cellspacing="0">
                <tbody>
                    <tr>
                        <td valign="middle" style="line-height: 19px; "><img width="16" src="http://www.ibm.com/i/v14/icons/u_bold.gif" height="16" border="0" alt="" /><br />
                        </td>
                        <td valign="top" align="right" style="line-height: 19px; "><a href="http://www.ibm.com/developerworks/cn/opensource/os-maven2/index.html#main" class="fbox" style="color: #5c81a7; text-decoration: none; font-family: verdana, nsimSun, arial, sans-serif; font-size: 12px; line-height: 13px; "><strong>回页首</strong></a></td>
                    </tr>
                </tbody>
            </table>
            </td>
        </tr>
    </tbody>
</table>
<span  style="font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; "><br />
</span><span  style="font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; "><br />
</span>
<p style="padding-bottom: 8px; padding-top: 5px; margin-top: 0px; margin-bottom: 0px; font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; "><a name="N10153"><span class="atitle" style="font-family: Arial, sans-serif; font-weight: bold; font-size: 18px; ">使用简介</span></a></p>
<p style="padding-bottom: 8px; padding-top: 5px; margin-top: 0px; margin-bottom: 0px; font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; ">安装Maven2的步骤非常简单：首先从Maven官方网站下载相应的软件包，目前是Maven 2.0.1；然后解压，并设置环境变量M2_HOME= Maven2的解压安装目录；最后将%M2_HOME%/bin添加到path中，方便Maven在任何目录下运行。</p>
<p style="padding-bottom: 8px; padding-top: 5px; margin-top: 0px; margin-bottom: 0px; font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; ">Maven2的运行命令是mvn，使用mvn -h可以获得相关的帮助信息。常用情形：</p>
<ul style="margin-top: 2px; margin-bottom: 2px; padding-top: 2px; padding-bottom: 2px; font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; ">
    <li>创建Maven项目：mvn archetype:create</li>
    <li>编译源代码：mvn compile</li>
    <li>编译测试代码：mvn test-compile</li>
    <li>运行测试：mvn test</li>
    <li>产生site：mvn site</li>
    <li>打包：mvn package</li>
    <li>在本地Repository中安装jar：mvn install</li>
    <li>清除产生的项目：mvn clean</li>
</ul>
<p style="padding-bottom: 8px; padding-top: 5px; margin-top: 0px; margin-bottom: 0px; font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; ">或许是由于刚刚推出的缘故，Maven2目前还是有一些不尽如人意的地方。尤其是Report部分的plugin，有的是因为目前还没有，如junit-report。有的则是一些莫名其妙的问题，如checktyle和pmd，在本地locale下都无法正常工作。以pmd举例，在产生PMD报告时会抛出如下异常：</p>
<span  style="font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; "><br />
</span>
<table width="100%" cellpadding="0" cellspacing="0" border="0" style="font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; ">
    <tbody>
        <tr>
            <td class="code-outline" style="line-height: 19px; background-color: #eeeeee; padding-top: 5px; padding-right: 5px; padding-bottom: 5px; padding-left: 5px; ">
            <pre class="displaycode" style="margin-top: 0px; margin-bottom: 0px; font-family: 'Andale Mono', 'Lucida Console', Monaco, fixed, monospace; font-size: 11px; ">java.util.MissingResourceException: Can't find bundle for base name pmd-report,
            locale zh_CN
            at java.util.ResourceBundle.throwMissingResourceException(ResourceBundle
            .java:839)
            at java.util.ResourceBundle.getBundleImpl(ResourceBundle.java:808)
            at java.util.ResourceBundle.getBundle(ResourceBundle.java:702)
            &#8230;&#8230;
            </pre>
            </td>
        </tr>
    </tbody>
</table>
<span  style="font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; "><br />
</span>
<p style="padding-bottom: 8px; padding-top: 5px; margin-top: 0px; margin-bottom: 0px; font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; ">幸运的是，Maven2一出现就备受关注，要不了多长时间，诸如此类的问题应该就会很快解决。</p>
<span  style="font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; "><br />
</span>
<table border="0" cellspacing="0" cellpadding="0" width="100%" style="font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; ">
    <tbody>
        <tr>
            <td style="line-height: 19px; "><img width="100%" src="http://www.ibm.com/i/v14/rules/blue_rule.gif" height="1" alt="" /><br />
            <img alt="" width="8" height="6" border="0" src="http://www.ibm.com/i/c.gif" /></td>
        </tr>
    </tbody>
</table>
<table class="no-print" cellspacing="0" cellpadding="0" align="right" style="font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; ">
    <tbody>
        <tr align="right">
            <td style="line-height: 19px; "><img width="100%" height="4" src="http://www.ibm.com/i/c.gif" alt="" /><br />
            <table border="0" cellpadding="0" cellspacing="0">
                <tbody>
                    <tr>
                        <td valign="middle" style="line-height: 19px; "><img width="16" src="http://www.ibm.com/i/v14/icons/u_bold.gif" height="16" border="0" alt="" /><br />
                        </td>
                        <td valign="top" align="right" style="line-height: 19px; "><a href="http://www.ibm.com/developerworks/cn/opensource/os-maven2/index.html#main" class="fbox" style="color: #5c81a7; text-decoration: none; font-family: verdana, nsimSun, arial, sans-serif; font-size: 12px; line-height: 13px; "><strong>回页首</strong></a></td>
                    </tr>
                </tbody>
            </table>
            </td>
        </tr>
    </tbody>
</table>
<span  style="font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; "><br />
</span><span  style="font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; "><br />
</span>
<p style="padding-bottom: 8px; padding-top: 5px; margin-top: 0px; margin-bottom: 0px; font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; "><a name="N10189"><span class="atitle" style="font-family: Arial, sans-serif; font-weight: bold; font-size: 18px; ">结论</span></a></p>
<p style="padding-bottom: 8px; padding-top: 5px; margin-top: 0px; margin-bottom: 0px; font-family: verdana, nsimsun, sans-serif; font-size: 12px; line-height: 19px; ">Maven2在Maven1的优势基础之上，又向前迈进了一大步。它提供的这些新特性大大地缩短了开发管理中的工作量，使得开发人员将精力集中在实际的业务问题上。而且这些新特性对于简化使用，普及最佳实践，也起到了积极的作用。</p>
<img src ="http://www.blogjava.net/masen/aggbug/323129.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.blogjava.net/masen/" target="_blank">Masen</a> 2010-06-09 11:14 <a href="http://www.blogjava.net/masen/articles/323129.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>