<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    我的漫漫程序之旅

    專注于JavaWeb開發(fā)
    隨筆 - 39, 文章 - 310, 評(píng)論 - 411, 引用 - 0
    數(shù)據(jù)加載中……

    使用MyEclipse構(gòu)建MAVEN項(xiàng)目

    這里用的是MyEclpise的自帶的MAVEN插件。
    Maven最好配置成你自己安裝的那個(gè),MyEclipse自帶會(huì)有些許Bug。


    用nexus代理Maven的中央倉庫,setting.xml的配置文件修改內(nèi)容如下:
    <mirrors>
         <mirror>
              <id>nexus</id>
              <mirrorOf>*</mirrorOf>
              <name>Nexus Mirror</name>
              <url>http://localhost:8081/nexus/content/groups/public</url>
         </mirror>
      </mirrors>
      
      <profiles>
         <profile>
          <id>nexus</id>
          <repositories>
            <repository>
              <id>central</id>
              <url>http://central</url>
              <releases><enabled>true</enabled></releases>
              <snapshots><enabled>true</enabled></snapshots>
            </repository>
          </repositories>
         <pluginRepositories>
            <pluginRepository>
              <id>central</id>
              <url>http://central</url>
              <releases><enabled>true</enabled></releases>
              <snapshots><enabled>true</enabled></snapshots>
            </pluginRepository>
          </pluginRepositories>
        </profile>
      </profiles>
      <activeProfiles>
        <activeProfile>nexus</activeProfile>
      </activeProfiles>
    http://localhost:8081/nexus/content/groups/public 是倉庫組的地址。
    打下MyEclipse新建工程的界面,選擇Maven下的Maven Project,打開如下圖的向?qū)В?br />
    這里我們要選中create a simple project。
    點(diǎn)擊下一步,填寫GAV相關(guān)內(nèi)容。

    點(diǎn)擊完成后,我們就已經(jīng)成功創(chuàng)建了一個(gè)Maven project了。
    工程的默認(rèn)目錄結(jié)構(gòu)如下:


    所有的Java源文件都要寫在src/main/java目錄下,所有的測(cè)試類都要寫在src/test/java下面,這是Maven的默認(rèn)值。
    此時(shí),pom.xml里只有默認(rèn)的屬性
    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
      <modelVersion>4.0.0</modelVersion>
      <groupId>com.test</groupId>
      <artifactId>test</artifactId>
      <version>0.0.1-SNAPSHOT</version>
    </project>
    這是最精簡(jiǎn)的pom.xml了。
    這時(shí)我們加入junit的支持,新建一個(gè)測(cè)試類。
    在項(xiàng)目上右鍵Maven-Add Dependency,顯示如下界面:

    輸入junit加入測(cè)試支持類庫。
    在src/test/java下新建一個(gè)測(cè)試類如下:
    package com;
    import org.junit.Test;
    public class TestRun
    {
    @Test
    public void testA()
    {
    System.out.println("test a method ");
    }
    @Test
    public void testB()
    {
    System.out.println("test b method ");
    }
    }
    右鍵Run As ----- Maven test,進(jìn)行測(cè)試,顯示結(jié)果如下:



    [INFO] Scanning for projects
    [INFO]                                                                         
    [INFO] ------------------------------------------------------------------------
    [INFO] Building test 0.0.1-SNAPSHOT
    [INFO] ------------------------------------------------------------------------
    [INFO] 
    [INFO] --- maven-resources-plugin:2.5:resources (default-resources) @ test ---
    [debug] execute contextualize
    [WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent!
    [INFO] Copying 0 resource
    [INFO] 
    [INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ test ---
    [INFO] Nothing to compile - all classes are up to date
    [INFO] 
    [INFO] --- maven-resources-plugin:2.5:testResources (default-testResources) @ test ---
    [debug] execute contextualize
    [WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent!
    [INFO] Copying 0 resource
    [INFO] 
    [INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ test ---
    [INFO] Nothing to compile - all classes are up to date
    [INFO] 
    [INFO] --- maven-surefire-plugin:2.10:test (default-test) @ test ---
    [INFO] Surefire report directory: D:\workspace\test\target\surefire-reports

    -------------------------------------------------------
     T E S T S
    -------------------------------------------------------
    Running com.TestRun
    test a method 
    test b method 
    Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.071 sec

    Results :

    Tests run: 2, Failures: 0, Errors: 0, Skipped: 0

    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD SUCCESS
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 1.847s
    [INFO] Finished at: Tue Sep 11 14:20:59 CST 2012
    [INFO] Final Memory: 3M/6M
    [INFO] ------------------------------------------------------------------------
    ok,一個(gè)基本的maven項(xiàng)目已經(jīng)構(gòu)建完成。我們還可以將現(xiàn)存的java項(xiàng)目利用myclipse方便的轉(zhuǎn)換成maven project,此部分內(nèi)容我們?cè)谙乱还?jié)里討論。

    posted on 2012-09-11 14:25 々上善若水々 閱讀(67509) 評(píng)論(9)  編輯  收藏 所屬分類: Maven

    評(píng)論

    # re: 使用MyEclipse構(gòu)建MAVEN項(xiàng)目  回復(fù)  更多評(píng)論   

    看你寫的挺好的 ,但是為什么沒有圖片呀???求圖關(guān)注中
    2013-02-25 20:35 | 731982341@qq.com

    # re: 使用MyEclipse構(gòu)建MAVEN項(xiàng)目  回復(fù)  更多評(píng)論   

    UP主,你的圖片掛了。求補(bǔ)
    教程不錯(cuò)=.=
    2013-03-21 09:48 | Mr.zhan9

    # re: 使用MyEclipse構(gòu)建MAVEN項(xiàng)目  回復(fù)  更多評(píng)論   

    @Mr.zhan9
    已修復(fù)
    2013-03-26 17:26 | 々上善若水々

    # re: 使用MyEclipse構(gòu)建MAVEN項(xiàng)目  回復(fù)  更多評(píng)論   

    MYECLIPSE的版本?
    2013-09-17 19:38 | REDJACK

    # re: 使用MyEclipse構(gòu)建MAVEN項(xiàng)目  回復(fù)  更多評(píng)論   

    不錯(cuò),寫的很好。
    2013-12-11 09:32 | 不凡

    # re: 使用MyEclipse構(gòu)建MAVEN項(xiàng)目[未登錄]  回復(fù)  更多評(píng)論   

    2015-04-18 14:15 | w

    # re: 使用MyEclipse構(gòu)建MAVEN項(xiàng)目[未登錄]  回復(fù)  更多評(píng)論   

    用nexus代理Maven的中央倉庫,setting.xml的配置文件修改內(nèi)容如下:

    這里的setting.xml 必須這樣嗎? 可以默認(rèn)的吧
    2015-10-13 10:40 | 1

    # re: 使用MyEclipse構(gòu)建MAVEN項(xiàng)目  回復(fù)  更多評(píng)論   

    nexus需要安裝嗎?
    2016-02-26 11:50 | Jagtu

    # re: 使用MyEclipse構(gòu)建MAVEN項(xiàng)目  回復(fù)  更多評(píng)論   

    <profile>
    <id>nexus</id>
    <repositories>
    <repository>
    <id>central</id>
    <url>http://central</url>
    <releases><enabled>true</enabled></releases>
    <snapshots><enabled>true</enabled></snapshots>
    </repository>
    </repositories>
    <pluginRepositories>
    <pluginRepository>
    <id>central</id>
    <url>http://central</url>
    <releases><enabled>true</enabled></releases>
    <snapshots><enabled>true</enabled></snapshots>
    </pluginRepository>
    </pluginRepositories>
    </profile>


    這一塊去掉了貌似也沒什么問題
    2016-08-29 15:08 | 龍平

    只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。


    網(wǎng)站導(dǎo)航:
     
    主站蜘蛛池模板: 97av免费视频| 日韩精品无码免费专区午夜不卡| 粉色视频在线观看www免费| 美女被吸屁股免费网站| 久久久WWW免费人成精品| 午夜爽爽爽男女免费观看影院| 亚洲电影在线免费观看| 色吊丝最新永久免费观看网站| 亚洲精品成人片在线观看| 亚洲AV无码国产在丝袜线观看| youjizz亚洲| 香蕉国产在线观看免费| 亚洲一区二区在线免费观看| 一二三四影视在线看片免费 | 全部免费毛片在线播放| 色se01短视频永久免费| yy6080久久亚洲精品| 亚洲V无码一区二区三区四区观看| 亚洲同性男gay网站在线观看| 国产精品亚洲精品日韩电影| a级毛片无码免费真人久久| 免费无码黄十八禁网站在线观看| 国产中文字幕免费| 亚洲国产精品第一区二区| 亚洲另类无码专区首页| 两个人看的www免费| 欧洲精品成人免费视频在线观看| 亚洲人成无码网WWW| 亚洲一欧洲中文字幕在线| 一级a性色生活片久久无少妇一级婬片免费放 | 亚洲自偷自拍另类图片二区| 国产亚洲精品AAAA片APP| 久久国产免费观看精品| 日本免费一本天堂在线| 亚洲成人动漫在线| 国产亚洲综合久久| 亚洲精品免费在线| 国产美女亚洲精品久久久综合| 亚洲人成人网毛片在线播放| 免费看黄的成人APP| 国产精品自在自线免费观看|