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

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

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

    積少成多

    垃圾堆

      BlogJava :: 首頁 :: 聯(lián)系 :: 聚合  :: 管理
      29 Posts :: 1 Stories :: 5 Comments :: 0 Trackbacks
    Maven的功能
    • 遵循最佳實(shí)踐,簡單的建立項(xiàng)目-在分秒之間建立一個(gè)新的項(xiàng)目或者模塊。
    • 在多個(gè)項(xiàng)目之間統(tǒng)一使用。
    • 依附環(huán)境的管理,包括自動(dòng)的升級。
    • 方便地在同一時(shí)間參加多個(gè)項(xiàng)目。
    • 大且不斷增長的庫和元數(shù)據(jù)可供食用。
    • 可擴(kuò)展,用java或腳本語言開發(fā)插件
    • 加入新的功能只需要很少或不需要額外的配置
    • Ant任務(wù)支持依附環(huán)境管理,在Maven之外進(jìn)行發(fā)布。
    • 在大多數(shù)情況下,maven不需要腳本就可以編譯多個(gè)項(xiàng)目,打包成jar, war或基于元數(shù)據(jù)進(jìn)行項(xiàng)目發(fā)布
    • 清晰的項(xiàng)目信息:Maven能夠建立一個(gè)站點(diǎn)或PDF文檔,其中包括項(xiàng)目的一些基本信息和報(bào)表。
    • 版本管理和項(xiàng)目發(fā)布:不需要太多的額外配置,maven會和你的代碼管理器整合,然后基于一定的tag,來幫助管理你的版本。它也可以為其他的項(xiàng)目發(fā)布到一個(gè)地方。maven也支持發(fā)布成jar或其他歸檔的文件或是源代碼。
    • 依附管理:maven建議集中管理jar庫。項(xiàng)目客戶可以到集中的jar庫中下載任何包。這允許maven用戶可以在多個(gè)項(xiàng)目中公用jar,并鼓勵(lì)項(xiàng)目之間的交流。

     

    Maven如何幫助改進(jìn)我們的開發(fā)過程?

    通過標(biāo)準(zhǔn)的約定和實(shí)踐Maven對你的build流程提供幫助,加速你的開發(fā)周期并同時(shí)幫助你的項(xiàng)目成功。

    下面我們提供一些例子讓你來運(yùn)行maven!

    如何建立Maven?

    基本上,maven默認(rèn)的配置已經(jīng)足夠面對大部分情況了,但是如果你需要修改緩存策略或者設(shè)置http代理,你就需要自己建立一個(gè)配置。詳細(xì)請參考Guide to Configuring Maven

     

    如何建立我的第一個(gè)maven項(xiàng)目?

    我們會使用maven的archetype 機(jī)制來建立我們的第一個(gè)maven項(xiàng)目。maven中,archetype是項(xiàng)目模版,在加上一些用戶的輸入來建立一個(gè)maven的項(xiàng)目。我們會向你展示archetype機(jī)制如何工作。更多請參考

     


    創(chuàng)建最簡單的maven項(xiàng)目,只需要執(zhí)行下面的命令就可以了

    mvn archetype:generate \   -DarchetypeGroupId=org.apache.maven.archetypes \   -DgroupId=com.mycompany.app \   -DartifactId=my-app 

    執(zhí)行命令后,首先,你會發(fā)現(xiàn)一個(gè)叫my-app的文件夾建立了,其中有pom.xml文件,內(nèi)容如下:

    <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/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.mycompany.app</groupId>
    <artifactId>my-app</artifactId>
    <packaging>jar</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>Maven Quick Start Archetype</name>
    <url>http://maven.apache.org</url>
    <dependencies>
    <dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>3.8.1</version>
    <scope>test</scope>
    </dependency>
    </dependencies>
    </project>

    pom.xml里有項(xiàng)目的project object model。pom是maven的基本工作單元。This is important to remember because Maven is inherently project-centric in that everything revolves around the notion of a project. 簡單的說,pom包含了所有項(xiàng)目的重要信息。更多請參考Introduction to the POM.

    This is a very simple POM but still displays the key elements every POM contains, so let's walk through each of them


    to familiarize you with the POM essentials:

    • project This is the top-level element in all Maven pom.xml files.
    • modelVersion This element indicates what version of the object model this POM is using. The version of the model itself changes very infrequently but it is mandatory in order to ensure stability of use if and when the Maven developers deem it necessary to change the model.
    • groupId This element indicates the unique identifier of the organization or group that created the project. The groupId is one of the key identifiers of a project and is typically based on the fully qualified domain name of your organization. For example org.apache.maven.plugins is the designated groupId for all Maven plug-ins.
    • artifactId This element indicates the unique base name of the primary artifact being generated by this project. The primary artifact for a project is typically a JAR file. Secondary artifacts like source bundles also use the artifactId as part of their final name. A typical artifact produced by Maven would have the form <artifactId>-<version>.<extension> (for example, myapp-1.0.jar).
    • packaging This element indicates the package type to be used by this artifact (e.g. JAR, WAR, EAR, etc.). This not only means if the artifact produced is JAR, WAR, or EAR but can also indicate a specific lifecycle to use as part of the build process. (The lifecycle is a topic we will deal with further on in the guide. For now, just keep in mind that the indicated packaging of a project can play a part in customizing the build lifecycle.) The default value for the packaging element is JAR so you do not have to specify this for most projects.
    • version This element indicates the version of the artifact generated by the project. Maven goes a long way to help you with version management and you will often see the SNAPSHOT designator in a version, which indicates that a project is in a state of development. We will discuss the use of snapshots and how they work further on in this guide.
    • name This element indicates the display name used for the project. This is often used in Maven's generated documentation.
    • url This element indicates where the project's site can be found. This is often used in Maven's generated documentation.
    • description This element provides a basic description of your project. This is often used in Maven's generated documentation.

    For a complete reference of what elements are available for use in the POM please refer to our POM Reference. Now let's get back to the project at hand.

    After the archetype generation of your first project you will also notice that the following directory structure has been created:

    my-app |-- pom.xml `-- src     |-- main     |   `-- java     |       `-- com     |           `-- mycompany     |               `-- app     |                   `-- App.java     `-- test         `-- java             `-- com                 `-- mycompany                     `-- app                         `-- AppTest.java 

    As you can see, the project created from the archetype has a POM, a source tree for your application's sources and a source tree for your test sources. This is the standard layout for Maven projects (the application sources reside in ${basedir}/src/main/java and test sources reside in ${basedir}/src/test/java, where ${basedir} represents the directory containing pom.xml).

    If you were to create a Maven project by hand this is the directory structure that we recommend using. This is a Maven convention and to learn more about it you can read our Introduction to the Standard Directory Layout.

    Now that we have a POM, some application sources, and some test sources you are probably asking ...


     









     

    posted on 2012-04-16 17:05 思無 閱讀(512) 評論(0)  編輯  收藏

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


    網(wǎng)站導(dǎo)航:
     
    主站蜘蛛池模板: 2021在线永久免费视频| EEUSS影院WWW在线观看免费| 在线观看www日本免费网站| 国产∨亚洲V天堂无码久久久| 成人国产精品免费视频| 亚洲fuli在线观看| 91av视频免费在线观看| 久久亚洲精品无码AV红樱桃| 美丽姑娘免费观看在线观看中文版| 久久精品国产亚洲AV网站| 日本免费中文字幕| 亚洲电影免费观看| 无码一区二区三区亚洲人妻| 日本免费中文字幕在线看| 激情小说亚洲图片| 久久影视国产亚洲| 久艹视频在线免费观看| 亚洲精品无码久久毛片波多野吉衣| 久久九九兔免费精品6| 亚洲免费日韩无码系列 | 性感美女视频免费网站午夜| 亚洲 日韩经典 中文字幕 | 亚洲第一区香蕉_国产a| 最近免费字幕中文大全视频| 精品日韩99亚洲的在线发布| 色吊丝最新永久免费观看网站| 国产成人亚洲精品91专区高清 | 亚洲最大福利视频网站| 成视频年人黄网站免费视频| 亚洲自偷自偷图片| 91免费国产精品| 国产精品手机在线亚洲| 亚洲情综合五月天| 69天堂人成无码麻豆免费视频| 国产精品亚洲色图| 亚洲av午夜成人片精品网站 | 日韩高清免费观看| 西西人体免费视频| 亚洲AV成人影视在线观看| 国产亚洲精午夜久久久久久| 91免费播放人人爽人人快乐|