Maven Custom Archetype

Source: Internet
Author: User

MAVEN provides archetype to help us build the skeleton of a project quickly and easily. However, the archetype version in the Central warehouse is too old to build a good project, need to modify a lot of information, is very troublesome, then how to customize a archetype is very necessary.

To customize a archetype, you must follow these steps:

1, hand-built good one perfect project;

2, enter the project catalogue, retain SRC and pom.xml, delete other documents;

3, the execution instruction mvn archetype:create-from-project at this time will automatically generate the target directory;

4, execute the instruction CD target/generated-sourced/archetype switch directory;

5, execution Instructions mvn Install then a archetype is installed in the local library, in Eclipse can be selected to build the project;

================================================

A problem may occur during this process, with the following excerpt:

1, under the Windows platform, perform the third step, throw the following error

[INFO] BUILD Failure[info]------------------------------------------------------------------------[INFO] Total Time:2.294S[info] finished at: .- the-09t16:Geneva:Wuyi+ ,:xx[INFO] Final memory:17m/164m[info]------------------------------------------------------------------------[ERROR] Failed to execute goal org.apache.maven.plugins:maven-archetype-plugin:2.4: Create-from-project (default-CLI) on project test03:error Configuring command-line. Reason:maven executable not found at: *\apache-maven-3.3.9\bin\mvn.bat--[Help1][error][error] To see the full stack trace of the errors, re-run Maven with the-e switch.

For this error, go to the Apache-maven-3.3.9\bin directory, copy the Mvn.cmd, and rename it to Mvn.bat.

2. When you select Archetype to build a WEB project, the \web-inf\web.xml declaration version= "1.0" of the first line also changes along with the version number that was filled in when the build was built.

To solve this problem, before performing the fifth step, go to the SRC directory in the current directory, find the Web. XML, change the first ${version} variable to 1.0.

3, using Eclipse Build, when published into the middleware, access path or archetype path, resulting in project name access failed

The solution to this problem is that, when building archetype, the finalname in the Pom.xml file in the archetype is made with variables, i.e. <finalname>${project.artifactid}</ Finalname>

Maven Custom 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.