Nexus的安装以及怎样配置proxy就不讲解了,网上随便搜索就是一堆。我所在搜狐武汉研发这边暂时还没有Nexus可用,所以抽了时间我就搭建了一个。安装和搭建及其简单,但是如何配置到项目呢,尤其是有多种配置方式。
Maven 3.1.0 发布,项目构建工具 http://www.linuxidc.com/Linux/2013-07/87403.htm
Linux 安装 Maven http://www.linuxidc.com/Linux/2013-05/84489.htm
Maven3.0 配置和简单使用 http://www.linuxidc.com/Linux/2013-04/82939.htm
Ubuntu下搭建sun-jdk和Maven2 http://www.linuxidc.com/Linux/2012-12/76531.htm
Maven使用入门 http://www.linuxidc.com/Linux/2012-11/74354.htm
1.想要让maven项目能够从Nexus中取jar,其实只需要在POM中配置如下一段即可:
<repositories>
<repository>
<snapshots>
<enabled>true</enabled>
</snapshots>
<id>public</id>
<name>Public Repositories</name>
<url>http://127.0.0.1:8081/nexus/content/groups/public/</url>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>public</id>
<name>Public Repositories</name>
<url>http://127.0.0.1:8081/nexus/content/groups/public/</url>
</pluginRepository>
</pluginRepositories>
2. 按照上述方式其实可以简单使用Nexus了,但是难道每个项目都需要这样配置一下,很麻烦,所以下面有另外一种办法,修改全局settings.xml文件,在文件里面增加如下代码:
<profiles>
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>false</enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>central</id>
<url>http://central</url>
<releases><enabled>true</enabled></releases>
<snapshots><enabled>false</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
<profile>
<!--this profile will allow snapshots to be searched when activated-->
<id>public-snapshots</id>
<repositories>
<repository>
<id>public-snapshots</id>
<url>http://public-snapshots</url>
<releases><enabled>false</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>public-snapshots</id>
<url>http://public-snapshots</url>
<releases><enabled>false</enabled></releases>
<snapshots><enabled>true</enabled></snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>nexus</activeProfile>
<activeProfile>public-snapshots</activeProfile>
</activeProfiles>
这样配置完成后,就可以在任何maven项目中使用咱们的Nexus了。
更多详情见请继续阅读下一页的精彩内容: http://www.linuxidc.com/Linux/2014-06/103054p2.htm
