www.hj6666.comEclipse构建Maven项目

算法 ww9992019com 发表于 1 周前

www.hj6666.com开户请拨15894452155抖音主播教室摆拍中山南头镇6uKoB2<div style="width:100%;float:left;" class="article-content">

                <input type="hidden" name="article_id" id="article_id" value="1969">
                <input type="hidden" name="catid" id="catid" value="0">

                <p>

<span><strong>1. 安装m2eclipse插件 </strong></span><br>

   要用Eclipse构建Maven项目,我们需要先安装meeclipse插件 <br>

   点击eclipse菜单栏Help-&gt;Eclipse Marketplace搜索到插件Maven Integration for Eclipse 并点击安装即可,如下图:</p>

<p>

 <br>

<img alt="" height="343" src="/uploads/allimg/140215/1101256062-0.png" width="376"><br>

 </p>

<p>

安装成成之后我们在Eclipse菜单栏中点击File-&gt;New-&gt;Other,在弹出的对话框中会看到如下图所示:</p>

<p>

<br>

<img alt="" height="364" src="/uploads/allimg/140215/110125J63-1.png" width="354"><br>

 </p>

<p>

<span><strong>2. 构建Maven项目</strong></span><span>  </span></p>

<p>

     </p>

<p>

      以eclipse3.6为例</p>

<p>

      1)创建简单Maven项目</p>

<p>

           点击Eclipse菜单栏File-&gt;New-&gt;Ohter-&gt;Maven得到如下图所示对话框:</p>

<p>

           <br>

<img alt="" height="335" src="/uploads/allimg/140215/1101251452-2.png" width="370"><br>

 </p>

<p>

选中Maven Project并点击Next,到下一个对话框继续点击Next得到如下对话框</p>

<p>

<br>

<img alt="" height="391" src="/uploads/allimg/140215/110125F47-3.png" width="403"><br>

 如图示操作,选择maven-archetype-quickstart,点击Next</p>

<p>

<br>

<img alt="" height="403" src="/uploads/allimg/140215/1101251318-4.png" width="423"><br>

 按图示填写好groupId, artfactId,version等信息,点击Finish。</p>

<p>

由此我们成功创建了一个简单的Maven项目,项目结构如图所示</p>

<p>

<br>

<img alt="" src="/uploads/allimg/140215/1101256194-5.png"><br>

 </p>

<p>

     2)创建Maven web项目</p>

<p>

     操作跟创建简单Maven项目类似,点击Eclipse菜单File-&gt;New-&gt;Other-&gt;Maven-&gt;Maven Project</p>

<p>

     在选择maven-archetype的界面进行如下操作:</p>

<p>

     <br>

<img alt="" height="487" src="/uploads/allimg/140215/1101255292-6.png" width="540"><br>

 点击Next,填写好相应的groupId,artifactId,version等信息,点击Finish</p>

<p>

得到的Maven web项目结构如下图所示:</p>

<p>

 <br>

<img alt="" src="/uploads/allimg/140215/1101253N2-7.png"><br>

 </p>

<p>

 右击项目,点击Properties-&gt;Project Facets</p>

<p>

<br>

<img alt="" height="482" src="/uploads/allimg/140215/110125D23-8.png" width="616"><br>

 </p>

<p>

如上图可以看到项目为web2.3 java1.5 当然我们也可以改成我们所需要的版本,打开xml文件my-app-web/.settings/org.eclipse.wst.common.project.facet.core.xml,进行修改即可:</p>

<div class="dp-highlighter" id="" dejavu sans mono vera consolas new monospace width: overflow: auto margin-left: padding: word-break: break-all word-wrap: break-word color: rgb line-height:>

<div class="bar">

    <div class="tools">

        Xml代码  <a title="收藏这段代码"><img alt="收藏代码" class="star" src="/uploads/allimg/140215/110125A06-9.png"></a></div>

</div>

<ol class="dp-xml" start="1">

    <li>

        <span><span class="tag">&lt;?</span><span class="tag-name">xml</span> <span class="attribute">version</span>=<span class="attribute-value">"1.0"</span> <span class="attribute">encoding</span>=<span class="attribute-value">"UTF-8"</span><span class="tag">?&gt;</span>  </span></li>

    <li>

        <span><span class="tag">&lt;</span><span class="tag-name">faceted-project</span><span class="tag">&gt;</span>  </span></li>

    <li>

        <span>  <span class="tag">&lt;</span><span class="tag-name">fixed</span> <span class="attribute">facet</span>=<span class="attribute-value">"wst.jsdt.web"</span><span class="tag">/&gt;</span>  </span></li>

    <li>

        <span>  <span class="tag">&lt;</span><span class="tag-name">installed</span> <span class="attribute">facet</span>=<span class="attribute-value">"java"</span> <span class="attribute">version</span>=<span class="attribute-value">"1.5"</span><span class="tag">/&gt;</span>  </span></li>

    <li>

        <span>  <span class="tag">&lt;</span><span class="tag-name">installed</span> <span class="attribute">facet</span>=<span class="attribute-value">"jst.web"</span> <span class="attribute">version</span>=<span class="attribute-value">"2.3"</span><span class="tag">/&gt;</span>  </span></li>

    <li>

        <span>  <span class="tag">&lt;</span><span class="tag-name">installed</span> <span class="attribute">facet</span>=<span class="attribute-value">"wst.jsdt.web"</span> <span class="attribute">version</span>=<span class="attribute-value">"1.0"</span><span class="tag">/&gt;</span>  </span></li>

    <li>

        <span><span class="tag">&lt;/</span><span class="tag-name">faceted-project</span><span class="tag">&gt;</span>  </span></li>

</ol>

</div>

<p>

 </p>

<p>

     3)导入Maven项目</p>

<p>

          在Eclipse project explorer中右击,在弹出框中选择import,得到如下图所示:          <br>

<img alt="" height="424" src="/uploads/allimg/140215/1101254A1-10.png" width="470"><br>

 </p>

<p>

      选择Existing Maven Projects,并点击Next,得到如下图所示对话框:</p>

<p>

     <br>

<img alt="" height="459" src="/uploads/allimg/140215/11012535I-11.png" width="487"><br>

 </p>

<p>

选择一个已经创建好的Maven项目,并点击Finish。</p>

<p>

由此,导入Maven项目成功</p>

<p>

 </p>

<p>

 </p>

<p>

    </p>

<p>

<span><strong>3. 运行Maven命令</strong></span></p>

<p>

     </p>

<p>

    右击项目,点击Run as,如下图:</p>

<p>

 <br>

<img alt="" height="219" src="/uploads/allimg/140215/110125Dc-12.png" width="437"><br>

 </p>

<p>

 即可看到有很多现有的maven命令,点击即可运行,并在控制台可以看到运行信息</p>

<p>

 如果你想运行的maven命令在这里没有找到,点击Maven build创建新的命令,操作如下图所示:</p>

<p>

<br>

<img alt="" height="218" src="/uploads/allimg/140215/1101252126-13.png" width="440"><br>

 </p>

<p>

 如下图填入Maven命令,点击Run即可</p>

<p>

<br>

<img alt="" height="482" src="/uploads/allimg/140215/1101253314-14.png" width="520"><br>

 </p>

<p>

新增的maven命令可以通过如下方式找到,并再次运行:</p>

<p>

<br>

<img alt="" height="170" src="/uploads/allimg/140215/1101251046-15.png" width="442"><br>

 </p>

<p>

 <br>

<img alt="" height="235" src="/uploads/allimg/140215/1101251S1-16.png" width="372"></p>



                <br>
                <p style="text-align:center;float:left;width:100%;margin-top:24px;margin-bottom:18px;">
                        <button class="layui-btn layui-btn-danger" id="btn-reward"> ¥ 我要打赏 </button>  
                        <button class="layui-btn" id="article-perfect">
                            <i class="layui-icon layui-icon-edit"></i>教程纠错
                        </button>
                        <button class="layui-btn layui-btn-normal" id="action-collection">
                            <i class="layui-icon layui-icon-rate"></i>收藏
                        </button>
                </p>



                <div style="width:100%;margin-bottom: 16px; height: 32px;margin-top:18px;float:left;">

                    <span style="float:left;">上一篇:<a href="http://f2e.im/u/ww9992019com" title="NetBeans IDE集成Maven"><i class="layui-icon"></i>
                            NetBeans IDE集成Maven</a></span>
                                            <span style="float:right;">下一篇:<a href="http://f2e.im/u/ww9992019com" style="float:right;" title="下一篇:Maven启用代理访问"><i class="layui-icon"></i>
                            Maven启用代理访问</a></span>
                                            <div id="googlead" style="float:left;margin-top:8px;">
                        <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
                        <!-- yiibai下方 -->
                        <ins class="adsbygoogle" style="display:inline-block;width:728px;height:90px" data-ad-client="ca-pub-1090193214637198" data-ad-slot="6494738921"></ins>
                        <script>
                            (adsbygoogle = window.adsbygoogle || []).push({});
                        </script>
                    </div>
                </div>

                <div style="width:100%;margin-top:18px;float:left;">


            </div>
暂无回复,说出你的观点吧
登录后即可参与回复