Nexus和Maven集成的两种方式

 Nexus安装配置完成后,需要在Maven中进行相应的配置才能正常使用,配置方式主要有两种:

方式1.在~/.m2/setting.xml文件(或者&M2_HOME/conf/settings.xml文件)中配置镜像,如:

		<mirror>  
			<id>nexus</id>  
			<mirrorOf>central</mirrorOf>  
			<name>Public Repositories</name>  
			<url>http://127.0.0.1:9002/nexus/content/groups/public</url>   
		</mirror>
 

方式2:在项目的pom.xml文件中配置仓库地址,如:

      <repositories>  
		<repository>   
			<id>public</id>  
			<name>Public Repositories</name>  
			<url>http://localhost:9002/nexus/content/repositories/central</url>
			<releases>
				<enabled>true</enabled>
			</releases>
			<snapshots>
				<enabled>false</enabled>
			</snapshots>  
		</repository>  
	</repositories>
	<pluginRepositories>  
		<pluginRepository>  
			<id>public</id>  
			<name>Public Repositories</name>  
			<url>http://localhost:9002/nexus/content/repositories/central</url>
			<releases>
				<enabled>true</enabled>
			</releases>
			<snapshots>
				<enabled>false</enabled>
			</snapshots>  
		</pluginRepository>  
	</pluginRepositories>

     很显然,使用方式2需要在所有项目的pom.xml文件中进行配置,造成了重复,如果同时使用方式1和方式2进行了配置,那么Maven会优先使用settings.xml文件中的镜像地址进行查找.

猜你喜欢

转载自manysysy.iteye.com/blog/1070196
今日推荐