Create and use the maven Project Skeleton Archetype

Source: Internet
Author: User

What is Maven archetype? Simply put, it is the basic template of a Maven project. With this template, we can quickly create a new project of this type, and also build our own Project Skeleton.
The Archetype function provided by Maven is implemented by the plug-in Maven archetype in.
Address: http://maven.apache.org/archetype/maven-archetype-plugin/

 

Main commands:

  • Archetype: Generate creates a Maven project from the Project Skeleton. The old version uses archetype: Create
  • Archetype: Create-from-Project: Create a Project Skeleton based on a project.

Use archetype: generate to create a project

MVN archetype: Generate command parameter explanation
Project parameters:

Parameters

Description

Groupid

ID of the group to which the current application belongs

Artifactid

ID of the current application

Package

The name of the root package used for code generation. If it is not provided, archetypegroupid is used by default.

Prototype parameter table

 

Parameters Description

Archetypegroupid

Group ID of the prototype (archetype)

Archetypeartifactid

Prototype (archetype) ID

Archetypeversion

Archetype version

Archetyperepository

Resource library containing the prototype (archetype)

Archetypecatalog

Archetype classification, which is classified by location:
'Local' local, usually the archetype-catalog.xml file of the local repository
Remote is the central repository of Maven.
File: //... 'specifies the local file location archetype-catalog.xml directly
Http: //... 'or 'https: // File Location archetype-catalog.xml on the...' NETWORK
'Internal'
The default value is remote and local.

Filter

Filter artifactid or groupid: artifactid when searching

Package

The name of the root package used for code generation. If it is not provided, archetypegroupid is used by default.

Command example:
Create a simple web project
MVN archetype: generate-dgroupid = com. Charles
-Dartifactid = webappdemo
-Dpackage = com. Charles. webappdemo
-Darchetypeartifactid = Maven-Archetype-webapp
-Dversion = 1.0-dinteractivemode = No

Create a struts2 WEB Project
MVN archetype: generate-B-dgroupid = com. mycompany. mysystem
-Dartifactid = mywebapp
-Darchetypegroupid = org. Apache. Struts
-Darchetypeartifactid = struts2-archetype-convention
-Darchetypeversion = <current_struts_version>
-Dremoterepositories = http://struts.apache.org
The Archetype type provided by Maven by default can refer to the http://maven.apache.org/guides/introduction/introduction-to-archetypes.html

 

Generate an archetype from an existing project

MVN clean archetype: Create-from-project-darchetype. properties =./archetype. properties-darchetype. filteredextentions = Java, XML, JSP, properties, SQL

First, an archetype. properties file is defined in the directory where the command line is executed.
Tableprefix is used in the qucikstart project and you want to replace the content in the new project.
-Dfilteredextentions: Maven does not scan SQL files by default, but you want to modify tableprefix here.
Properties reference http://maven.apache.org/archetype/maven-archetype-plugin/create-from-project-mojo.html

Create and use the maven Project Skeleton Archetype

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.