[Go to] create a custom archetype using Maven

Source: Internet
Author: User

You can create your own archetype in either of the following ways: Create from project

1First, use eclipse to create a new Maven project, and then put the configured public items under the corresponding directory
For example, some common Java code will be stored under the src/main/Java directory;
Some common configuration files will be put under the src/main/Resources Directory;

For the javeee project, some JSP files will be stored in the src/main/webapp directory.

 

2And then add the plug-in to the POM. xml file of the maven project.
========================================================== ==========
<Plugins>
<Plugin>
<Groupid> org. Apache. Maven. plugins </groupid>
<Artifactid> Maven-Archetype-plugin </artifactid>
<Version> 2.2 </version>
</Plugin>
</Plugins>
========================================================== ==========

For example:




3Open the CMD window, CD to the root directory of the maven project just created, and run the maven command:
MVN archetype: Create-from-Project
The generated-sources directory is generated under the target directory, which is the generated archetype.

4. Run cd in the generated-sourced/archetype directory and run the maven command:
MVN install
In this way, the custom Archetype is installed in the local repository.
The Archetype installation address is specified in the conf/settings. xml file under the maven installation directory (<localrepository> bytes ).
The default value is ~ The/. m2 directory generates a archetype-catalog.xml file (in the same directory as the default settings. XML ),
Declares the groupid, artifactid, and other attributes of the archetype.
Because during the creation of Maven projects in eclipse, the "Default local" point to the address is ~ /. M2,
Therefore, the file archetype-catalog.xml will be automatically read by ECLIPSE,
When using eclipse to create a Maven project, you can find the custom archetype name in the "Default local" field.

5. In Maven settings of eclipse, the local repository address pointed to by settings. xml selected by user settings and under the maven installation directory
Eclipse can only read the source file of the custom archetype that was just installed when the settings. xml file points to the same path,
In this way, eclipse can copy the source file and create a project.

6. To uninstall the installed archetype, you only need ~ /. M2 directory under the archetype-catalog.xml file corresponding to the <archetype> byte segment Delete,
Delete the files under the corresponding groupid and artifactid in the local repository.

7. Archetype installed in the local repository can only be used by you. If you want to share the archetype, use the deploy command in Step 4 instead of the install command.
========================================================== ========================================================== =====
========================================================== ========================================================== =====

 

Original article

Use maven3 to create a custom Archetype

Http://blog.csdn.net/uncleja/article/details/7252780

Related Article

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.