一、本地創建一個符合自己公司規範的多模塊的maven項目
二、在項目根pom文件中添加maven archetype插件
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-archetype-plugin</artifactId>
<version>3.0.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
三、創建archetype到本地倉庫
# 打開IDEA底部終端控制檯
# CD到項目根目錄執行命令
mvn archetype:create-from-project
四、生成archetype模板
## 進入archetype目錄
cd target/generated-sources/archetype/
mvn install
## 生成archetype-catalog.xml文件
mvn archetype:crawl
執行以上命令後在本地倉庫的根目錄中會生成archetype-catalog.xml文件
archetype的內容如下,其中artifactId和groupId待會我們生成的時候要用到
<?xml version="1.0" encoding="UTF-8"?>
<archetype-catalog xsi:schemaLocation="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-catalog/1.0.0 http://maven.apache.org/xsd/archetype-catalog-1.0.0.xsd"
xmlns="http://maven.apache.org/plugins/maven-archetype-plugin/archetype-catalog/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<archetypes>
<archetype>
<groupId>com.generated.boot</groupId>
<artifactId>generated-archetype</artifactId>
<version>1.0-SNAPSHOT</version>
<description>generated</description>
</archetype>
<archetype>
<groupId>org.apache.maven.archetypes</groupId>
<artifactId>maven-archetype-quickstart</artifactId>
<version>1.1</version>
<description>quickstart</description>
</archetype>
</archetypes>
</archetype-catalog>
五、打開項目目錄下的target\generated-sources\archetype\pom.xml文件,添加distributionManagement配置,然後mvn deploy
<distributionManagement>
<repository>
<id>nexus-releases</id>
<name>Nexus Release Repository</name>
<url>http://nexus.***.com:8089/nexus/content/groups/public/</url>
</repository>
<snapshotRepository>
<id>nexus-snapshots</id>
<name>Nexus Snapshot Repository</name>
<url>http://nexus.***.com:8089/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
</project>
milian-archetype\target\generated-sources\archetype>mvn deploy
提示build success的話,你的archetype就上傳到服務器了,默認的artifactId就是原來項目的artifactId加上-archetype