自建 Nexus OSS 私库无法下载Snapshot版本依赖的问题

自建 Nexus OSS 私库无法下载Snapshot版本依赖的问题

 

转自  http://blog.sina.com.cn/s/blog_70ae1d7b0102wo9h.html

 

 

       无法从Nexus OSS中下载对应的SNAPSHOT版依赖,但该依赖确实存在于仓库中,

    而获取Release版依赖却又正常,如果你也遇到这个情况,那么请看如下解决方案:

 

      错误信息:

                     ERROR : Could not find artifact com.example:example:jar:1.0-SNAPSHOT

      原因:

             从Release仓库下载Snapshot版依赖包,这当然找不到啦,我的原因是没有在Maven的setting.xml

             配置文件中指明那些仓库可下载release依赖、哪些仓库可下载snapshot依赖。

      解决:

                  在setting.xml中的节点添加一个profile:

 

 

<profile>
	<id>nexus</id>
	<!--Enable snapshots for the built in central repo to direct -->
	<activation>
		<activeByDefault>true</activeByDefault>
	</activation>
	<!--all requests to nexus via the mirror -->
	<repositories>
		<repository>
			<id>maven-releases</id>
			<url>http://xxxx.com:8081/content/repositories/releases/</url>
			<releases>
				<enabled>true</enabled>
			</releases>
			<snapshots>
				<enabled>false</enabled>
			</snapshots>
		</repository>
		<repository>
			<id>maven-snapshots</id>
			<url>http://xxxx.com:8081/content/repositories/snapshots/</url>
			<releases>
				<enabled>false</enabled>
			</releases>
			<snapshots>
				<enabled>true</enabled>
			</snapshots>
		</repository>
	</repositories>
</profile>
 

 

 

 

 

 

 

 

猜你喜欢

转载自yangzhonglei.iteye.com/blog/2422223