管理maven的仓库目前知道的有三种
archiva, artifactory以及nexus,貌似nexus目前最流行。放上下载地址https://www.sonatype.com/oss-thank-you-zip
目前我下的是nexus-2.14.2-01-bundle.zip 运行这个东西首先需要JDK。所以我们需要首先安装JDK1.8
以centos 为例,大概就这么几步
yum update (更新这事看你爱好吧,一般不跑也没事)
rpm -qa | grep -E ‘^open[jre|jdk]|j[re|dk]’ (查老版本的JDK有没有)
加入有老版本的话,需要
yum remove java-1.6.0-openjdk
yum remove java-1.7.0-openjdk
系统干净了。就赶紧去这个地址下载http://www.oracle.com/technetwork/java/javase/downloads/index.html oracle jdk 1.8
我下的是jdk-8u25-linux-x64.rpm 然后打安装的命令
rpm -ivh jdk-8u25-linux-x64.rpm
现在oracle jdk 1.8就安装完成了
然后进入nexus的解压目录 ./bin/nexus start 运行起来看看。
运行tail -f logs/wrapper.log可以看到这次启动的结果
没问题的话。输入ip:8081/nexus就可以看到启动画面啦
首先是登陆,默认账号密码 admin admin123
进入central的configuration,设置Download Remote Indexes 为true
apache snapshot也可以设置。
下面是使用
在pom.xml中增加 这层的上一层就是<project>
<repositories>
<repository>
<id>nexus</id>
<name>Nexus</name>
<url>http://x.x.x.x:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>nexus</id>
<name>Nexus</name>
<url>http://x.x.x.x:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
好了。这样这个项目就可以使用了
所有项目使用需要改变setting.xml
<mirrors>
<mirror>
<id>nexus</id>
<mirrorOf>*</mirrorOf>
<url>http://x.x.x.x:8081/nexus/content/groups/public</url>
</mirror>
</mirrors>
也可以用别人私服,,谷歌和oschina的(暂未验证)
<mirrors>
<mirror>
<id>google-maven-central</id>
<name>Google Maven Central</name>
<url>https://maven-central.storage.googleapis.com</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
<mirrors>
<mirror>
<id>nexus-osc</id>
<mirrorOf>*</mirrorOf>
<name>Nexus osc</name>
<url>http://maven.oschina.net/content/groups/public/</url>
</mirror>
</mirrors>