maven uses archetype to generate project skeleton

1. Premise and environmental reference

    Operating system: win10

    Development tools: idea2020.2

    maven: 3.8.5 or 3.6.3

    Prerequisite: Complete the previous article Nexus and maven integration

2. Generate project skeleton

1. Copy the maven settings configuration in the previous chapter to the C:\Users\Administrator\.m2 folder (.m2 folder under Windows users)

2. Enter the project project to ensure that the project depends on the maven-archetype-plugin plug-in, and add new rules in the root directory of the project

#确保pom中的插件依赖:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-archetype-plugin</artifactId>
</plugin>

#在项目根目录下新建archetype.properties模板规则文件

# 添加不需要放到模板的正则匹配
excludePatterns=.idea/**,README.md,.mvn/wrapper/*,.gitignore
# 需要替换处理的文件后缀,默认没有yml、yaml
archetype.filteredExtensions=java,yml,yaml,xml,txt,groovy,cs,mdo,aj,jsp,gsp,vm,html,xhtml,properties,.classpath,.project

3. Enter your newly created project, clean it up and re-depend on it, and finally execute the mvn archetype:create-from-project command to generate the template.

4. Enter the archetype directory generated above and execute the mvn install command.

 5. Execute mvn archetype:crawl and template upload command mvn deploy

3. Use of template projects

1. Open the local maven warehouse to find the necessary information for the template project (the template is generated using maven3.8.5. Since my idea is the 2020 version, the maven that pulls the project uses version 3.6.3)

2. Open idea-->new-->project and configure the above information.

3. Select the template project you just selected and go to the next step. The remaining steps are the same as the usual new maven project.

 4. Effect display (template code has been automatically generated)

Guess you like

Origin blog.csdn.net/qq_29653373/article/details/124351029