乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      Maven項(xiàng)目管理工具:MavenArchetype(原型/模板)

       碼農(nóng)9527 2021-09-30

          Archetype是Maven項(xiàng)目的模板工具包,它定義了Maven項(xiàng)目的基本架構(gòu)。Archetype為開發(fā)人員提供了數(shù)千種創(chuàng)建Maven項(xiàng)目的模板,Maven通過這些模板可以幫助用戶快速的生成項(xiàng)目的目錄結(jié)構(gòu)以及POM文件。

          MavenArchetype由下面5個(gè)模塊組成:

          maven-archetype-plugin:Archetype插件。

          archetype-packaging:用于描述Archetype的生命周期與構(gòu)建項(xiàng)目軟件包。

          archetype-models:用于描述類與引用。

          archetype-common:核心類。

          archetype-testing:用于測(cè)試MavenArchetype的內(nèi)部組件。

          maven-archetype-plugin

          我們知道Maven的所有功能都是通過插件實(shí)現(xiàn)的,Archetype也不例外,它是由一個(gè)名為maven-archetype-plugin的插件實(shí)現(xiàn)的,該插件提供了ArcheType的所有功能。

          雖然ArcheType只是一個(gè)插件,但其應(yīng)用范圍十分的廣泛,幾乎所有的主流IDE(例如Eclipse、NetBeans和IntelliJIDEA)都在集成Maven時(shí)著重繼承了Archetype特性,以方便用戶快速的創(chuàng)建Maven項(xiàng)目。

          執(zhí)行以下命令可以幫助用戶快速的創(chuàng)建Maven項(xiàng)目.

      mvn archetype:generate1復(fù)制代碼類型:[java]

          為了滿足用戶的需求,Maven為用戶提供了大量不同類型的Archetype模板(到本教程編寫時(shí)共提供了2916個(gè)Archetype模板)。

          在執(zhí)行以上命令時(shí),Maven會(huì)輸出一個(gè)ArcheType列表,每個(gè)ArcheType前面都對(duì)應(yīng)一個(gè)編號(hào),我們可以根據(jù)不同的需求選擇合適的Archetype。

          說到底,Archetype只是一個(gè)模板,為了保持模板的通用性,它的很多重要的信息都是可配置的,在用戶選擇了Archetype后,還需要提供一些關(guān)于項(xiàng)目的基本參數(shù),主要包括以下參數(shù):

          groupId

          artifactId

          version

          package

          在輸入以上參數(shù)后,Archetype插件就能夠?yàn)橛脩羯身?xiàng)目的基本目錄結(jié)構(gòu)和POM文件了。

          示例1

          1.打開命令控制臺(tái),跳轉(zhuǎn)到D:\maven目錄中,執(zhí)行以下Maven命令。

      mvn archetype:generate1復(fù)制代碼類型:[python]

          Maven將開始處理,并要求選擇所需的項(xiàng)目模板。

      [INFO] Scanning for projects...
      [INFO]
      [INFO] ------------------< org.apache.maven:standalone-pom >-------------------
      [INFO] Building Maven Stub Project (No POM) 1
      [INFO] --------------------------------[ pom ]---------------------------------
      [INFO]
      [INFO] >>> maven-archetype-plugin:3.2.0:generate (default-cli) > generate-sources @ standalone-pom >>>
      [INFO]
      [INFO] <<< maven-archetype-plugin:3.2.0:generate (default-cli) < generate-sources @ standalone-pom <<<
      [INFO]
      [INFO]
      [INFO] --- maven-archetype-plugin:3.2.0:generate (default-cli) @ standalone-pom ---
      [INFO] Generating project in Interactive mode
      ……
      2860: remote -> tk.skuro:clojure-maven-archetype (A simple Maven archetype for Clojure)2861: remote -> top.lshaci:framework-archetype (top lshaci framework maven archetype)2862: remote -> top.marchand.archetype:sie-xf-prio-dep-import-generic ([ELS] Modèle de projet d'import Flash basé sur l'importeur générique)2863: remote -> top.ssrsdev:eightroes-plugin-archetype (eightroes-webapp-archetype)2864: remote -> top.ssrsdev:eightroes-webapp-archetype (eightroes-webapp-archetype)2865: remote -> tr.com.lucidcode:kite-archetype (A Maven Archetype that allows users to create a Fresh Kite project)2866: remote -> tr.com.obss.sdlc.archetype:obss-archetype-java (This archetype provides a common skelton for the Java packages.)2867: remote -> tr.com.obss.sdlc.archetype:obss-archetype-webapp (This archetype provides a skelton for the Java Web Application packages.)2868: remote -> ua.co.gravy.archetype:single-project-with-junit-and-slf4j (Create a single project with jUnit, Mockito and slf4j dependencies.)2869: remote -> uk.ac.ebi.gxa:atlas-archetype (Archetype for generating a custom Atlas webapp)2870: remote -> uk.ac.gate:gate-plugin-archetype (Maven archetype to create a new GATE plugin project.)2871: remote -> uk.ac.gate:gate-pr-archetype (Maven archetype to create a new GATE plugin project including a sample PR class (an empty LanguageAnalyser).)
      2872: remote -> uk.ac.nactem.argo:argo-analysis-engine-archetype (An archetype which contains a sample Argo (UIMA) Analysis Engine)
      2873: remote -> uk.ac.nactem.argo:argo-reader-archetype (An archetype which contains a sample Argo (UIMA) Reader)
      2874: remote -> uk.ac.rdg.resc:edal-ncwms-based-webapp (-)2875: remote -> uk.co.markg.archetypes:java11-junit5 (An archetype for generate java 11 projects with junit 5.)2876: remote -> uk.co.nemstix:basic-javaee7-archetype (A basic Java EE7 Maven archetype)2877: remote -> uk.co.solong:angular-spring-archetype (So Long archetype for RESTful spring services with an AngularJS frontend. Includes debian deployment)2878: remote -> us.fatehi:schemacrawler-archetype-maven-project (-)2879: remote -> us.fatehi:schemacrawler-archetype-plugin-command (-)2880: remote -> us.fatehi:schemacrawler-archetype-plugin-dbconnector (-)2881: remote -> us.fatehi:schemacrawler-archetype-plugin-lint (-)2882: remote -> ws.osiris:osiris-archetype (Maven Archetype for Osiris)2883: remote -> xyz.luan.generator:xyz-gae-generator (-)2884: remote -> xyz.luan.generator:xyz-generator (-)2885: remote -> za.co.absa.hyperdrive:component-archetype (-)Choose a number or apply filter (format: [groupId:]artifactId, case sensitive contains): 1744:1234567891011121314151617181920212223242526272829303132333435363738394041復(fù)制代碼類型:[java]

          2.直接回車,選擇默認(rèn)選項(xiàng)(1744:maven-archetype-quickstart)。

          接下來,Maven選擇Archetype版本。

      Choose org.apache.maven.archetypes:maven-archetype-quickstart version:1: 1.0-alpha-12: 1.0-alpha-23: 1.0-alpha-34: 1.0-alpha-4 5: 1.06: 1.17: 1.38: 1.4Choose a number: 8:12345678910復(fù)制代碼類型:[java]

          直接回車,選擇默認(rèn)選項(xiàng)(8:maven-archetype-quickstart:1.4)。

          Maven要求提供項(xiàng)目的詳細(xì)信息,根據(jù)要求輸入項(xiàng)目的詳細(xì)信息,若使用默認(rèn)值,則直接回車即可。

      Define value for property 'groupId': net.biancheng.www
      Define value for property 'artifactId': thirdMaven
      Define value for property 'version' 1.0-SNAPSHOT: :
      Define value for property 'package' net.biancheng.www: :1234復(fù)制代碼類型:[java]

          Maven要求用戶確認(rèn)信息,直接回車或輸入字母Y再按下回車鍵確認(rèn)信息。若信息有誤,則需要先輸入除字母Y之外得其他字母按鈕,在回車即可重新輸入。

      Confirm properties configuration:
      groupId: net.biancheng.www 
      artifactId: thirdMaven
      version: 1.0-SNAPSHOTpackage: net.biancheng.www
      Y: :123456復(fù)制代碼類型:[java]

          以上信息確認(rèn)完成過后,Maven開始構(gòu)建項(xiàng)目結(jié)構(gòu),并顯示如下內(nèi)容。

      [INFO] ----------------------------------------------------------------------------
      [INFO] Using following parameters for creating project from Archetype: maven-archetype-quickstart:1.4[INFO] ----------------------------------------------------------------------------
      [INFO] Parameter: groupId, Value: net.biancheng.www
      [INFO] Parameter: artifactId, Value: thirdMaven
      [INFO] Parameter: version, Value: 1.0-SNAPSHOT
      [INFO] Parameter: package, Value: net.biancheng.www
      [INFO] Parameter: packageInPathFormat, Value: net/biancheng/www
      [INFO] Parameter: package, Value: net.biancheng.www
      [INFO] Parameter: version, Value: 1.0-SNAPSHOT
      [INFO] Parameter: groupId, Value: net.biancheng.www
      [INFO] Parameter: artifactId, Value: thirdMaven
      [INFO] Project created from Archetype in dir: d:\maven\thirdMaven
      [INFO] ------------------------------------------------------------------------
      [INFO] BUILD SUCCESS
      [INFO] ------------------------------------------------------------------------
      [INFO] Total time:  02:39 min[INFO] Finished at: 2021-03-03T16:18:11+08:00[INFO] ------------------------------------------------------------------------12345678910111213141516171819復(fù)制代碼類型:[python]

          項(xiàng)目結(jié)構(gòu)

          進(jìn)入D:\maven目錄,我們可以看到Maven已經(jīng)創(chuàng)建了一個(gè)名為thirdMaven項(xiàng)目,其目錄結(jié)構(gòu)如下圖。

          Maven為項(xiàng)目生成了一個(gè)POM文件,如下所示。

      <?xml version="1.0" encoding="UTF-8"?>
      <project xmlns="http://maven./POM/4.0.0" xmlns:xsi="http://www./2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven./POM/4.0.0 http://maven./xsd/maven-4.0.0.xsd">
       <modelVersion>4.0.0</modelVersion>
       <groupId>net.biancheng.www</groupId>
       <artifactId>thirdMaven</artifactId>
       <version>1.0-SNAPSHOT</version>
       <name>thirdMaven</name>
       <!-- FIXME change it to the project's website -->
       <url>http://www.</url>
       <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.7</maven.compiler.source>
        <maven.compiler.target>1.7</maven.compiler.target>
       </properties>
       <dependencies>
        <dependency>
         <groupId>junit</groupId>
         <artifactId>junit</artifactId>
         <version>4.11</version>
         <scope>test</scope>
        </dependency>
       </dependencies>
       <build>
        <pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
         <plugins>
       <!-- clean lifecycle, see https://maven./ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
       <plugin>
        <artifactId>maven-clean-plugin</artifactId>
        <version>3.1.0</version>
       </plugin>
       <!-- default lifecycle, jar packaging: see https://maven./ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
       <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <version>3.0.2</version>
       </plugin>
       <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.8.0</version>
       </plugin>
       <plugin>
        <artifactId>maven-surefire-plugin</artifactId>
        <version>2.22.1</version>
       </plugin>
       <plugin>
        <artifactId>maven-jar-plugin</artifactId>
        <version>3.0.2</version>
       </plugin>
       <plugin>
        <artifactId>maven-install-plugin</artifactId>
        <version>2.5.2</version>
       </plugin>
       <plugin>
        <artifactId>maven-deploy-plugin</artifactId>
        <version>2.8.2</version>
       </plugin>
       <!-- site lifecycle, see https://maven./ref/current/maven-core/lifecycles.html#site_Lifecycle -->
       <plugin>
        <artifactId>maven-site-plugin</artifactId>
        <version>3.7.1</version>
       </plugin>
       <plugin>
        <artifactId>maven-project-info-reports-plugin</artifactId>
        <version>3.0.0</version>
       </plugin>
         </plugins>
        </pluginManagement>
       </build>
      </project>123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869復(fù)制代碼類型:[java]

          Maven創(chuàng)建項(xiàng)目時(shí),還自動(dòng)生成了兩個(gè)示例類文件:App.java和AppTest.java。

          App.java代碼如下。 

      package net.biancheng.www;
      /**
      * Hello world!
      */
      public class App { public static void main(String[] args) {  System.out.println("Hello World!");
       }
      }123456789復(fù)制代碼類型:[python]

          AppTest.java代碼如下。

      package net.biancheng.www;import static org.junit.Assert.assertTrue;import org.junit.Test;
      /**
      * Unit test for simple App.
      */
      public class AppTest {
       /**
        * Rigorous Test :-)
        */ @Test
       public void shouldAnswerWithTrue() {
        assertTrue(true);
       }
      }

        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評(píng)論

        發(fā)表

        請(qǐng)遵守用戶 評(píng)論公約

        類似文章 更多