制作自己的maven archetype

1. 到工程所在目录

mvn clean
mvn archetype:create-from-project

2. 修改 产生的target/generated-srouces/archetype/pom.xml, 添加自己的maven私服地址,为了deploy

<!-- Maven server -->
	<repositories>
		<repository>
			<id>local-nexus</id>
			<name>private repository nexus</name>
			<url>http://ip:8081/nexus/content/groups/public/</url>
			<releases>
				<enabled>true</enabled>
			</releases>
			<snapshots>
				<enabled>true</enabled>
			</snapshots>
		</repository>
	</repositories>

	<pluginRepositories>
		<pluginRepository>
			<id>local-nexus</id>
			<name>private plugin nexus</name>
			<url>http://ip:8081/nexus/content/groups/public/</url>
			<releases>
				<enabled>true</enabled>
			</releases>
			<snapshots>
				<enabled>true</enabled>
			</snapshots>
		</pluginRepository>
	</pluginRepositories>

	<distributionManagement>
		<repository>
			<id>releases</id>
			<name>Nexus Release Repository</name>
			<url>http://ip:8081/nexus/content/repositories/releases/</url>
		</repository>
		<snapshotRepository>
			<id>snapshots</id>
			<name>Nexus Snapshot Repository</name>
			<url>http://ip:8081/nexus/content/repositories/snapshots/</url>
		</snapshotRepository>
	</distributionManagement>

3. 到target/generated-srouces/archetype 目录

mvn clean compile
mvn deploy

 

4. 如果出现说没权限deploy,则要在.m2/setting.xml中加入相应的maven私服deploy权限:

<server>
      <id>releases</id>
      <username>deployment</username>
      <password>deploy</password>
    </server>
	
	<server>
      <id>snapshots</id>
      <username>deployment</username>
      <password>deploy</password>
    </server>

 

猜你喜欢

转载自vilight.iteye.com/blog/1876676