maven-003-Private Custom maven archetype

Source: Internet
Author: User

When using Maven to create a project module, the directory created by default archetype template, and the default Unit test tool for JUnit 3.8.1, and some commonly used resource files directory, configuration file (for example: log4j configuration file, Web page development commonly used template file style files, etc. need to be created manually, copy, then how to customize a suitable for their own habits of the archetype?

The Maven-archetype-plugin plug-in enables you to create a archetype template file based on an existing catalog structure. Here are the steps to create:

  

1, first, through Eclipse to create a project, according to their own habits to create a resource directory structure, and the corresponding resource files copied to the corresponding resource file directory, the configuration of the Pom file (for example: Project module information, developers, copyright information, TestNG and other jar package version, etc.)

  

2, add the following plug-in information in the Project engineering Pom file

1     <Build>2         <Plugins>3             <plugin>4                 <groupId>Org.apache.maven.plugins</groupId>5                 <Artifactid>Maven-archetype-plugin</Artifactid>6                 <version>2.4</version>7             </plugin>8         </Plugins>9     </Build>

3, enter the project root directory, execute command: mvn archetype:create-from-project, generate corresponding archetype.

During the execution, if the following error message appears, you can copy Mvn.cmd to mvn.bat in the corresponding directory of MAVEN, and then execute the command again: MVN archetype:create-from-project.

  

4. After successful execution, the \generated-sources\archetype directory will be generated in the target directory, the archetype directory is the generated archetype

  

5. Enter the archetype directory you just generated, execute the command: mvn install, the archetype you created can be installed in the local warehouse, and the MVN deploy can be installed to the remote warehouse.

6. Create a new MAVEN project project in Eclipse, and when Eclipse's maven setup "User Settings" selects the settings.xml point to the local warehouse and the warehouse where archetype was previously installed, you will see that you have just created The archetype, as follows:

    

After you create the project module, you can read the source files from the defined archetype.

7, if you want to delete the newly installed archetype, only need to delete the {User directory}/.m2/archetype-catalog.xml file archetype, and the local warehouse to delete the corresponding files.

  

At this point, maven-003-personalized maven archetype successfully completed, I hope this article can give you a reference to a beginner maven.

Finally, very grateful to the pro-stop, I hope this article can be pro helpful. Warmly welcome the kiss to discuss together and progress together. Thank you so much! ^_^

  

maven-003-Private Custom maven 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.